PEP 704 - Require virtual environments by default for package installers

Some additional more content-relevant notes on the PEP, originally made on the review:

  • What counts as a “virtual environment”? Only an environment created with venv/virtualenv? What about Conda environments? Or PEP 582 environments? Or other types of isolated environments? IMO, the PEP should either explicitly define this, or link (:term:) to a precise and authoritative definition, e.g. in the PyPA glossary.

  • [Also, what counts as “an installer”? Obviously, pip counts (as its mentioned by name), and I’m assuming Hatch, PDM and Poetry count as well when used in that capacity, while apt, dnf, brew and choco don’t, though that isn’t explicitly stated.

    If you limit it to “Python-specific” installer, what about tools like shiv, pex, etc.? And what about, of course, Conda? IMO, the PEP should provide a precise definition of that term and examples of what tools would and would not quality (similar to PEP 668 for what qualifies as an externally-managed environment).

  • Further, what “Python version” is being referred to—the version in the environment being installed in to? The version in the installer’s own runtime? Something else? The PEP should be specific here.

Workflow tools (which manage virtual environments for the user, under the hood) should be unaffected, since they should already be using the virtual environment for running the installer.

They will be affected if they don’t use venv/virtualenv virtual environments (e.g. Conda envs, I’d assume PDM PEP 582 envs, and possibly others), assuming tools don’t detect them. Either way, seems like that should be explicitly addressed in the PEP.

FWIW, this is also my experience this or something somewhat similar is a pretty common workflow as well, what I often practice and recommend to others. Additionally, another very common scenario I run into a lot, both inside and outside of the sciences, is multiple libraries and/or applications developed together that interact and must live in the same environment.

Yeah; that was my concern above as well. My impression is that given how common this is on the interwebs and in printed messages, despite the fact that it is usually (though not always) a bad idea, that enough users are likely to do this such that this would be likely to be a large-scale UX problem.