gordon@dickens.com writes:
I am now running Python3.11 [using] the "apt autoremove" command which I did use during the OS upgrade.
This is not a problem, but you do have to upgrade your venv as well.
Why doesn't mailman3 work with Python3.11?
It works fine with Python 3.11. The problem is that the point of a venv is to freeze everything -- including the Python binary -- "in place". However, because (a) Python is extremely stable across minor releases and (b) it is important to keep up with bug fixes, especially security fixes, in Python, the venv usually symlinks to the /usr/bin/python3.x binary (which is usually a symlink to a 3.x.y executable). If /usr/bin/python3.9 disappears, that will, of course, leave your Python 3.9 venv with a bunch of dangling symlinks and nothing in the venv will work.
Does this mean that I will need to rebuild mailman3's venv everytime that python is upgraded?
No.
/path/to/new-python3.y -m venv --upgrade /path/to/venv
should upgrade the venv to use Python 3.y, without changing any of the installed package sources. I believe it also recompiles all the source.py to __pycache__/source.cpython-3y.pyc files for you, but that is merely a minor time saving for the next time you start Mailman since Python will automatically recompile when you change versions.
If you have upgraded the /usr/bin/python3 in place (apparently you did) you can simplify the above to
python3 -m venv --upgrade /path/to/venv
and venv will figure out the right symlink for you.
Caveat, I have never tried this, I just don't uninstall the old Python installations because as a developer I need to test Mailman against them. But that's what "python3 -m venv --help" tells me. :-)
If you don't trust my untested suggestions (and why should you? ;-), you can try
PYTHONPATH=/path/to/venv/site-packages python3 -m pip freeze
and if that looks sane (ie, a list of Mailman and Django related packages and their versions), you can redirect it into requirements.txt. Then if necessary you can blow away the original venv and start new with the upgraded Python 3 and exactly the same package versions you had before with
python3 -m pip install -r requirements.txt
You can also avoid the venv upgrade entirely by using
python3 -m venv --copies /path/to/venv
to build the venv in the first place, which as I understand it will copy the whole Python installation into the venv. But then you lose the benefit of Python bug fixes from your distro and of course the space saving of symlinks.
Steve