Update website code to use python 3.x

Bug #1762164 reported by kaputtnik on 2018-04-08
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Widelands Website

Bug Description

Since django v1.11 is the last version with support for python 2.7, update the website code to use python 3.x. We have time for this until 2020. Plan:

1. Reduce code basis:
1.1. Try to remove/exchange third party apps with python 3 compatible ones. Especially:
  - django-rating (done)
  - threadedcomments

1.2. Cleanup own code basis and remove unused code. E.g. pybb has code for private messages which is unused

2. Convert to python3.

The installed python3 version on the server is currently 3.4.3

Related branches

kaputtnik (franku) on 2018-05-09
description: updated
kaputtnik (franku) on 2018-10-17
description: updated
kaputtnik (franku) wrote :

Turns that this task is a bit difficult for me :-D :

- The highest Python version supported by Django 1.11 is 3.6
- On archlinux the used python version is 3.7
- Downgrading here to python 3.6 does not work, because libreoffice depends on Python version 3.7. And i need libreoffice for other stuff.

Currently i compile python 3.6 for myself and will try to create a virtualenvironment with that version.

I had also the idea to create a Virtual machine with Ubuntu running, but i guess it will be the same work in the end, beside it steals some resources from the host. Any other ideas for my problem?

GunChleoc (gunchleoc) wrote :

Ubuntu Bionic (18.04) has Python 3.6, so that's definitely an option.

Which Linux is running on the webhost?

Is is possible to install multiple Python 3 versions on Arch at the same time? Maybe you could use a symbolic link to the Python version that you need in the virtualenv then.

kaputtnik (franku) wrote :

The server runs with Ubuntu 14.04.5 LTS

This needs also updating, but i won't do it... because i have:
- no experience with servers
- afaik needs some changes to init files, where i have also no experience

My approach to use python 3.6 just worked fine. I should just use python 3.4 instead of 3.6 because 3.4 is available on the server...

Due to my first tests i found that we need updating BeautifulSoup before the website can run under python 3.x at all :-D

SirVer (sirver) wrote :

Support for Ubuntu 14.4 runs out in the first quarter of 2019. We must update the server to bionic beaver (18.04 LTS). The last time I did update the server, it went absolutely fine with in-place update, however this time it is better to restore from backup after reinstall. This is a lot of work, unfortunately :(

One reason is that in-place update cannot update the kernel version, which is pretty ancient on our machine. [1] seems to indicate that a new install is required to update the server's kernel version.

[1] https://serversupportforum.de/forum/virtuelle-server/60693-starto-vserver-plesk-dist-upgrade-ubuntu-16-04-a.html

kaputtnik (franku) wrote :

Sounds like a 12 hour job... Installing linux isn't really time consuming, in comparison with windows. I guess most of the time will be needed to install the needed additional packages, recreating the virtualenvironments and adjusting the start scripts.

Maybe it is a good idea to create a virtual machine with Ubuntu server 18.04 at home for testing purposes? So it would be possible to copy e.g. the scripts from the VM to the server. This may reduce the server downtime... just an idea.

GunChleoc (gunchleoc) wrote :

Sounds like a good idea if your computer is fast enough :)

kaputtnik (franku) wrote :

I have try'd a lot to get a VM to work with Ubuntu server working. Sometimes it works, sometimes not. It took me a lot of time to find the reason: For some reason the VM only works if i reboot the host... It seems a 'cold' boot (after disconnecting power) does not apply all capabilities. No idea why ... Booting twice my main machine (host) to get the VM to work, let me discourage the initial idea. Sorry, there is a lot of other stuff to do... So the idea to set up a VM to speed up the downtime was only made for other people as a proposal ;-)

GunChleoc (gunchleoc) wrote :

Downtime it is then. Your time is too valuable.

kaputtnik (franku) on 2018-12-16
description: updated
kaputtnik (franku) wrote :

I want to exchange the last column in the topics lists. Currently we have:

username >>
on date, time

were the '>>' (the link to the last post) is most annoying for me. It is very small.

My suggestion is:

first 30 chars of post ...
by username on date, time

were the 'first chars of post ...' will be the link to the last post.
See attachment for a comparison.

Another idea is to keep the old style, but 'username >>' will be the link to the last post.

Other ideas?

janus (janus-jhor) wrote :

die idee find ich gut aber ist dieser bug der richtige ort dafür?

GunChleoc (gunchleoc) wrote :

I like your attachment version. Jut make sure that the text will automatically break into multiple lines when the screen gets small, just like with the topic title.

kaputtnik (franku) wrote :

@janus: Das ist teil vom pybb_cleanup, und ich wusste sonst nicht wohin damit ;)

Thanks :-)

GunChleoc (gunchleoc) wrote :

Markdown text in topic preview

kaputtnik (franku) wrote :

pip warning:

DEPRECATION: Python 2.7 will reach the end of its life on January 1st, 2020. Please upgrade your Python as Python 2.7 won't be maintained after that date. A future version of pip will drop support for Python 2.7.

I set bug importance to high and work on this.

Changed in widelands-website:
importance: Medium → High
kaputtnik (franku) wrote :

Because using python 3.4 in combination with mysqlclient through an error:

unsupported operand type(s) for %: 'bytes' and 'tuple'

and python 3.4 isn't maintained anymore, i'll go on with python 3.6. We may have to wait updating the website until we have Ubuntu 18.04 running...

kaputtnik (franku) wrote :

Since python3.6 can not be installed on Ubuntu 14.04, we may have to use a ppa for that:


Because using ppa's is somehow dangerous: Any remarks?

GunChleoc (gunchleoc) wrote :

Maybe this can be coordinated with SirVer for the server move? We wouldn't have this problem then.

kaputtnik (franku) wrote :

Working on the port to python3 is independent from the server. But the difficulties i have is to get the changes into a branch. Form what i know i can't run the 2to3 script to read and write the same file file in one go. So my plan is to:

1. create a virtual environment running python3.6
2. run 'bzr init-repo code'
3. branch the current website in folder code/widelands_org
4. run pip install -r widelands_org/pip_requirements.txt
5. run 'bzr branch widelands_org widelands_py36'
6. purge the the contents of folder widelands_py36
7. run '2to3 --output-dir=code/widelands_py36 -W -n code/widelands_org', which converts each file in widelands_org to a new file in widelands_py36

I think this is the way to get a branch which reflect the changes to current trunk. Is there an easier way?

GunChleoc (gunchleoc) wrote :

I don't think so - your plan sounds OK.

kaputtnik (franku) wrote :

Ubuntu 18.04 ships python 3.6 and i ask janus how long will it will take to set up a server. He told me he needs approximately 1 hour. So once a server decision was made, i assume switching to the new server can be made in one or two weeks.

The branch (wlwebsite_py36) is working nicely so far :-)

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers