[issue23465] Implement PEP 486 - Make the Python Launcher aware of virtual environments

Paul Moore report at bugs.python.org
Fri Feb 20 17:17:14 CET 2015


Paul Moore added the comment:

Hmm, I didn't know that (although virtualenv-based environments don't have an equivalent to pyvenv.cfg).

But there's some confusion here. This patch only affects command line usage (running "py.exe" to start Python). I don't really see a use case for making "py -3" mean "the virtualenv if it's Python 3 otherwise ignore the virtualenv and use the system Python 3".

For scripts, shebang processing isn't altered. Nothing uses a virtualenv except "#!/usr/bin/env python". And that does so only because it searches PATH before looking at the registry. If you use "#!/usr/bin/env python3" it won't see a virtualenv because there is no python3.exe in a virtualenv...

The scope of this PEP is just to make the "py" command (with no explicit version) use an active virtualenv before falling back to the default Python. This is specifically to allow people who don't put Python on their PATH but use virtualenvs to use "py" consistently, rather than having to switch to "python" when they are in a virtualenv. See the PEP (specifically the rationale section) for details.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23465>
_______________________________________


More information about the Python-bugs-list mailing list