[Python-Dev] PEP 370 - per-user scripts directory on Windows

Paul Moore p.f.moore at gmail.com
Sun Feb 15 21:26:48 CET 2015


On 15 February 2015 at 19:23, Vinay Sajip <vinay_sajip at yahoo.co.uk> wrote:
> Paul Moore <p.f.moore <at> gmail.com> writes:
>
>> 2. It would be a nice, although extremely obscure, feature to be able
>> to allow people who want to keep Python off their path to set
>> VIRTUAL_ENV but *not* set PATH, so that py.exe does the right thing
>> but there's *still* no python.exe on PATH. Limit the dependency on a
>> single environment variable rather than two, in other words.
>
> If this is the case, then your patch may not work if PATH isn't set. If a
> shebang is found in a script, it is processed in maybe_handle_shebang(), which
> means that your code to look in a venv won't be hit (though if you rely on the
> PATH being correctly set, then it will work as expected because the handling
> for e.g. /usr/bin/env python searches the PATH).

Yes, when I was actually coding this, I backed down on this (I updated
the PEP accordingly). Now, running py.exe with no script will pick up
VIRTUAL_ENV, but when you run a script, you need the virtualenv to be
activated for this to work.

The original PEP said nothing about a PATH search for #!/usr/bin/env
python, so I mistakenly assumed there was no way currently to write a
script that worked with an activated virtualenv. When I found that the
code did this, I decided it was unnecessary to add extra tests and
complexity just to cater for a case that nobody was ever likely to
need.

Paul


More information about the Python-Dev mailing list