I think there could be a middle ground, that would be achieved by accepting something that merges PEP 582 (with some improvements perhaps) and of PEP 704 (Require virtual environments by default for installers). Something like this (rough, opinionated draft):
- If both
__pypackages__
is present and using a venv/conda env,[1] Python should raise a warning on startup, use only the venv/conda env,[2] and pip/package managers should refuse to install (with an escape hatch, i.e. an option to specify the destination). - If using a venv/conda env, Python should use packages from it and ignore system site-packages.
- If
__pypackages__
is present, Python should use packages from it and ignore system site-packages. - If neither venv/conda env nor
__pypackages__
are present, Python should use system site-packages, and pip should refuse to install (unless the user explicitly accepts making a mess in the system site-packages) and tell the user how to fix this, with__pypackages__
being the recommended fix (considering its simplicity for beginners) and venvs also being mentioned as a valid and supported option.
Regarding the cases with sharing a folder, all those cases are equally broken/problematic if you’re using virtual environments stored in .venv
in the project folder (as recommended by PEP 704). Even if you use something like .venv-windows
and .venv-linux
, the performance is terrible in the WSL2 case. Centrally-stored venvs would be immune from those problems, although note they were the minority in Brett’s recent Fediverse polls.
That said, the I don’t think those cases should be the deciding factor, and they are quite easy to fix (by eg. storing the code in the Linux filesystem on WSL2, by a .dockerignore
for Docker builds, or by limiting your Docker bind mounts to only the source code directories relevant at runtime). And if some workflows are severely hindered by PEP 582, they can keep using virtual environments (nobody is proposing to get rid of them)—but at the same time, many people, especially beginners, would benefit from a simplification to the environment management story.
-
Conda envs are taken into account too, in line with comments under PEP 704 discussion ↩︎
-
Or alternatively refuse to run, although that seems too strong. Or alternatively
__pypackages__
could win, but IMO an explicit mechanism should win over an implicit mechanism. ↩︎