Closed elikoga closed 2 months ago
~~Hm this doesn't look good. It seems like the appenv environment depends on the executing python version due to the unconditional pip install pip --upgrade
.
With newer python versions, creating a new venv doesn't include setuptools anymore, but batou requires setuptools and complains.~~
The correct choice is not to modify the pip freeze call, but instead install setuptools
Ah, I know what we need: #1
The update command needs to migrate the project for 3.12 by reinstalling the required packages and updating the lockfile based on that. In the end, the new lockfiles include an explicit setuptools dependency. The upgrade path is also handled and no erroneous project state is introduced
Since https://github.com/python/cpython/issues/95299 we need to ensure we have a setuptools ourselves. They changed
pip freeze
behaviour in python 3.12 too: https://github.com/pypa/pip/pull/12032This leaves us with 2 options:We could lock all dependencies withpip freeze --all
but:this would also lockpip
,wheel
to a specific version, which is a change in behaviourwe would need to update therequirements.lock
to update the version ofpip
usedWe could forbid projects with mixed python >= 3.12 and < 3.12 versions in theirappenv-python-preference
listthis would prevent the issue from happening in the first placewe would need to inform users about this changeTo understand the second option better, it is important to know thatbatou
only uses the first python version in theappenv-python-preference
list that is actually installed on the system.This means that if you have3.12,3.11
as yourappenv-python-preference
and3.12
is installed,batou
will use3.11
for lockfile preparation and3.12
for venv creation. The resulting lockfile will not containsetuptools
andpip freeze
will not showsetuptools
either. This lockfile is incompatible with python 3.12, and once a user without3.12
installed tries to create a venv, they will run into the issue described above.Also, if you have3.12,3.11
as yourappenv-python-preference
and3.11
is installed,batou
will use3.11
for lockfile preparation and3.11
for venv creation. The resulting lockfile will not containsetuptools
andpip freeze
will not showsetuptools
either. This does not immediately cause an issue, but once a user with3.12
installed tries to create a venv, they will run into the issue described above.This PR does
pip freeze --all --exclude pip
if both python >= 3.12 and < 3.12 are in theappenv-python-preference
list. This mimics the behaviour ofpip freeze
after the change in python 3.12.