Author vinay.sajip
Recipients brian.curtin, bryangeneolson, tim.golden, vinay.sajip
Date 2013-01-26.12:47:08
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1359204428.51.0.605504219833.issue17010@psf.upfronthosting.co.za>
In-reply-to
Content
When using an activated virtual environment, there is no need to use "py" - just use "python". Primarily, the launcher looks for a shebang line in a script to determine which interpreter to use for the script. If no shebang line can be found, it will launch "the default" Python, which is currently the most recent Python 2.x found in the registry. When invoked via py -3 (or with suitable settings in the configuration), it will use the most recent Python 3.x found in the registry. Since venv interpreters are not in the registry, they will never be invoked as the default Python. However, any scripts installed into venvs will have the correct shebang lines, so they will launch with the venv's interpreter.

I don't believe this is a bug, as the system is IMO working as designed and as per PEP 397. If the launcher is asked to launch a script which contains a shebang, while a venv is activated, it will run with the interpreter indicated by the shebang, rather than the venv's interpreter.

Perhaps one could consider an enhancement whereby if no shebang is found, a different approach is used to find the interpreter - e.g. looking for "python" on the path before looking in the registry to locate an interpreter. The question arises as to whether this should be tied to a specific condition such as the presence of an environment key PYLAUNCHER_USEPATH. (This is of course orthogonal to whether or not a venv is activated, but would have the desired effect when a venv is activated, without needing to tie the launcher to a virtualenv-specific environment value such as VIRTUAL_ENV.)
History
Date User Action Args
2013-01-26 12:47:08vinay.sajipsetrecipients: + vinay.sajip, tim.golden, brian.curtin, bryangeneolson
2013-01-26 12:47:08vinay.sajipsetmessageid: <1359204428.51.0.605504219833.issue17010@psf.upfronthosting.co.za>
2013-01-26 12:47:08vinay.sajiplinkissue17010 messages
2013-01-26 12:47:08vinay.sajipcreate