prestige
prestige copied to clipboard
When system Python is upgraded, and the venv is broken, recreate the venv automatically
Running ./manage build-all
gives the following error:
❯ ./manage build-all
✨ Built in 6.42s
dist/index.html 1.57 KB 1.56s
dist/favicon.7dcc8543.ico 15.04 KB 4.15s
dist/favicon-32x32.4aeda8d9.png 550 B 1.09s
dist/favicon-16x16.0caf70ef.png 341 B 4.19s
dist/index.1eb443b0.css 100.06 KB 1.51s
dist/index.cd578e5b.js 547.25 KB 4.19s
Traceback (most recent call last):
File "/home/lsi/Oss/prestige/venv/bin/pip", line 5, in <module>
from pip._internal.cli.main import main
ModuleNotFoundError: No module named 'pip'
Workaround
Before launching the build, in the prestige
folder, type the following command:
( source ./venv/bin/activate && python -m ensurepip )
After this, pip is installed in the virtual environment and future ./manage build-all
commands will be able to succeed.
That's very odd. The manage
script uses the venv
module to create the virtual environment, in the ensure-venv
command. This command should already run ensurepip
unless the --without-pip
argument is given, as per the docs at https://docs.python.org/3/library/venv.html. I also couldn't reproduce this. Can you confirm your platform and Python version where this is seen please?
I have found, the explanation. The venv was created by a build of a previous version of prestige. Dropping the venv folder and launching a new build solved the problem.
I see. Thanks for sharing that. I still find it a bit odd though, because I practically copy pasted the venv-creation code from the old makefile to the new manage script, so it isn't any different. What I've seen in the past is this happens when Python is updated. When Python is updated to a newer version, all virtualenv folders stop working and will need to be recreated. Can you see if this was the case for you?
Yes, in my environment, Python as been upgraded in the meantime.
Awesome, thanks for confirming that. Yeah, everytime Python is upgraded we have to deal with this. Perhaps we can make the manage
script just detect this, and re-create the venv folder. 🤔
I'll keep this issue open to do just that then.
Closing this since the project no longer uses Python.