On 2016-11-06, Chris Angelico <ros...@gmail.com> wrote:
> On Sun, Nov 6, 2016 at 3:03 PM, Jon Ribbens <jon+use...@unequivocal.eu> wrote:
>> I don't suppose anyone else more constructive and informed actually
>> knows the answer to my rather simple question of how Python knows
>> it's in a venv? ;-)
>
> Two ways.
>
> 1) Normally, you 'activate' the venv by sourcing a script into your
> shell. This modifies $PATH, $PYTHONHOME, and I think a couple of other
> environment variables.

It sets VIRTUAL_ENV, adds the virtualenv's bin directory to PATH,
and *unsets* PYTHONHOME if set. That's it (modulo storing old values
of variables and updating PS1 which is presumably just cosmetic).

> 2) If Python notices that its executable comes from a venv, it uses it.

Yes. My question is *how does it notice*?
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to