[Python-ideas] Draft PEP for virtualenv in the stdlib

Nick Coghlan ncoghlan at gmail.com
Wed Oct 26 04:05:31 CEST 2011


On Wed, Oct 26, 2011 at 11:51 AM, Barry Warsaw <barry at python.org> wrote:
> On Oct 26, 2011, at 01:15 AM, Vinay Sajip wrote:
>
>>Nick Coghlan <ncoghlan at ...> writes:
>>>
>>> I'd actually prefer that we use the explicit "sys.prefix" and
>>> "sys.venv_prefix" naming (with the latter set to None when not in a
>>> virtual env) and possibly offer a convenience API somewhere that hides
>>> the "sys.prefix if sys.venv_prefix is None else sys.venv_prefix"
>>> dance.
>>
>>But why is that better than a site.venv_prefix which points to a venv if
>>you're in one, and == sys.prefix if you're not?
>
> I'm not sure why either <wink>, but I prefer the original suggestion, as Vinay
> restates it here.

Yeah, having venv_prefix == prefix in the "not in a virtual env case"
is fine by me as well. I think Carl's right that it reads a little
oddly sometimes, but it's a better option than:
- further overloading "site" (when more than site-package may be
located using the venv prefix)
- requiring people to fall back to sys.prefix explicitly

The "am I in a virtual env?" check can then just be "if sys.prefix ==
sys.venv_prefix".

Cheers,
Nick.

-- 
Nick Coghlan   |   ncoghlan at gmail.com   |   Brisbane, Australia



More information about the Python-ideas mailing list