Mailcow-dockerized: Python 2.7 End of Life

Created on 10 Feb 2019  路  16Comments  路  Source: mailcow/mailcow-dockerized

The mailcow project uses some Python scripts in the containers, currently they all run with python 2.7. Since Python is end of life on 01.01.2020 according to the official website, I wanted to ask if there are any plans to switch to Python 3.x?

https://devguide.python.org/#status-of-python-branches

# docker exec mailcowdockerized_dockerapi-mailcow_1 python --version                                                                                                                                      
Python 2.7.15
# docker exec mailcowdockerized_dovecot-mailcow_1 python --version                                                                                                               
Python 2.7.13
# docker exec mailcowdockerized_netfilter-mailcow_1 python --version                                                                                                                                          
Python 2.7.15
# docker exec mailcowdockerized_postfix-mailcow_1 python --version                                                              
Python 2.7.15rc1
# docker exec mailcowdockerized_sogo-mailcow_1 python --version                                                                                                                             
Python 2.7.13
enhancement help-wanted medium priority

All 16 comments

I don't think SOGo uses any python stuff, same for Postfix (not sure). But we need to update dockerapi, dovecot and netfilter.

PRs are very, very welcome.

do you prefer alpine images with installed python or an official python image (python:3-alpine3.9)? i i always prefer the highest possible official docker image.

You cannot just change the base of the image. That's not how it works.

I know

We just need to port the scripts to be Py3 compatible. "Just".

All used images provide Py3.

Most scripts are already rewritten in Python3

The following is still missing:

dovecot

  • data/Dockerfiles/dovecot/Dockerfile: supervisor \
  • data/Dockerfiles/dovecot/Dockerfile: python-html2text \
  • data/Dockerfiles/dovecot/Dockerfile: python-jinja2 \
  • data/Dockerfiles/dovecot/Dockerfile: python-mysql.connector \
  • data/Dockerfiles/dovecot/Dockerfile: python-redis \
  • data/Dockerfiles/dovecot/quarantine_notify.py:#!/usr/bin/python
  • data/Dockerfiles/dovecot/quota_notify.py:#!/usr/bin/python

The scripts quarantine_notify.py and quota_notify.py have to be updated for python 3.
(I'll take a look at it when I have time. If anyone else is in the mood, please let me know. )

supervisor in version 3 uses only Python 2, with version 4 Python 3 support was added, the Linux distros use still version 3. Either we continue to use the linux distro version (currently Python 2) or we install the current version 4 using pip.

postfix

  • data/Dockerfiles/postfix/Dockerfile: supervisor \
  • data/Dockerfiles/postfix/Dockerfile: python-gpg \
  • data/Dockerfiles/postfix/zeyple.py:#!/usr/bin/env python

The zeyple.py script is already tested with Python 3.7, so we just have to update it to the current version and test it with Mailcow.

sogo

  • data/Dockerfiles/sogo/Dockerfile: supervisor \

@andryyy what do you think?

@andryyy Can you please have a look if python-gpg is still needed? I think after zeyple.py is removed python-gpg (is still python2) is no longer needed.

Thus only supervisor remains as Python2 application (in sogo-mailcow, postfix-mailcow, dovecot-mailcow), here we wait for an update of Debian to version 4.x.
https://tracker.debian.org/pkg/supervisor

@andryyy Can you please have a look if python-gpg is still needed? I think after zeyple.py is removed python-gpg (is still python2) is no longer needed.

You are correct, I removed it and will push it later. :)

Thus only supervisor remains as Python2 application (in sogo-mailcow, postfix-mailcow, dovecot-mailcow), here we wait for an update of Debian to version 4.x.

Yes. :( Perhaps I find time to switch to another SV, that is also able to do stuff like killing the container, when a service died.

I think supervisor is a good decision, I don't know a better alternative.
Since version 4.x python 3 is also supported.
In Debian 9 and 10 supervisor 3.x (python 2) is used, only from Debian 11 (it will take years until the release) supervisor 4.x (python 3) is used.

Either we just wait until Debian switches to supervisor 4.x or we install the current version using pip.

RUN apt-get update && apt-get install -y --no-install-recommends \
  ...
  - supervisor # remove 
  python3-pip \
  ...
  && pip3 install --no-cache-dir --upgrade setuptools supervisor \

CMD exec /usr/local/bin/supervisord -c /etc/supervisor/supervisord.conf

I just don't know if there really is a reason to change to version 4. More important was that the mailcow own scripts were switched to Python3, which has already happened.

Debian 9 and 10 will still be maintaining Python 2 beyond its official end-of-life, so there is no pressing reason to upgrade the containers with supervisord. We can just leave those containers on Python 2 until Debian 11 is released.

Also we need to adjust update.sh on Line 405 soonish since users can run into a 'deprecated' 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.
More details about Python 2 support in pip, can be found at 
https://pip.pypa.io/en/latest/development/release-process/#python-2-support

We can also add a hint so users can install pip3

It does not affect mailcow or the security of the server, so we can easily redirect this warning to dev null. mailcow is furthermore not responsible for pip on the local machine, perhaps it is even a good hint for the administrators to keep that in mind. Don't know.

perhaps it is even a good hint for the administrators to keep that in mind. Don't know.

I would prefer to add a hint so they are not scared when they update their mailcow and used pip to install docker-compose

Just hiding the warning now. :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

a3li picture a3li  路  3Comments

patrick7 picture patrick7  路  3Comments

pgollor picture pgollor  路  3Comments

constin picture constin  路  3Comments

bonanza123 picture bonanza123  路  3Comments