3 ms·
Isn't this the entire premise of using a virtual environment? My virtual environments all live in a directory structure akin to /hostname/{user}/venvs/{pyth
by noitpmeder 5y ago
Isn't this the entire premise of using a virtual environment?
My virtual environments all live in a directory structure akin to
/hostname/{user}/venvs/{python_version}/{venv_name}
This lets me both segment environments by name (aka by project), but also to have distinct versions of these environments if I need to use different python versions for whatever reason.
This is _entirely_ separate from the source code of my projects, which might live somewhere like the following:
/hostname/{user}/src/{project_name}
Another fun trick is using python entry points (https://packaging.python.org/en/latest/specifications/entry-points/ https://packaging.python.org/en/latest/specifications/entry-...) which wrap the actual execution of a python script with something akin to
sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
This has the effect of always using that virtual environment's python version, even if I have not "activated" the environment or messed with my path in any way.