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
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.
the dovecote and postfix python scripts
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
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
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
@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. :)