[Distutils] new zc.buildout and virtualenv no longer friends?

Gary Poster gary.poster at canonical.com
Fri Apr 30 22:46:39 CEST 2010


On Apr 30, 2010, at 4:34 PM, Carl Meyer wrote:

> Hi Gary,

Hi Carl.

> Gary Poster wrote:
>> 1. virtualenv fixes the -S flag.  I doubt the virtualenv maintainers
>> care, but if they did, that would be great.
> 
> Ian can correct if I'm wrong, but AFAIK that would be quite difficult.
> Virtualenv is built around a custom site.py; that's where all the magic
> happens. Without site.py all you've got is a relocated Python binary
> with a bare-bones mini-stdlib. You could place a complete copy of the
> stdlib inside each virtualenv; I think any other solution would involve
> re-creating virtualenv from the ground up.
> 
> There are some interesting alternative approaches for doing virtualenvs,
> such as http://github.com/kvbik/rvirtualenv/; but that one also depends
> on site.py. I'm not aware of any that don't.

My changes to zc.buildout rely on site.py as well, so I understand that it is critical.  However, the interpreter that z3c.recipe.scripts builds uses this trick, and honors -S, so maybe it is possible for virtualenv.  I don't know enough about the details to be confident.

>> 2. zc.buildout and bootstrap special case virtualenv: if virtualenv
>> is sniffed (handwave...), we don't use -S.  This is messy, but it
>> means that virtualenv users get what they want without fuss, and
>> non-virtualenv users can use a system Python without fuss.
> 
> FWIW, sniffing for virtualenv is quite easy (no hand-waving required!)
> Just check for hasattr(sys, 'real_prefix'). Pip uses this, so it's
> already depended on outside virtualenv.

Thank you, cool.

I decided to see if ConfigParser could be imported, since that's what virtualenv is using as a somewhat related internal bellweather.  Then, if virtualenv is changed to honor -S, normal functionality of the zc.buildout code will resume.

Gary


More information about the Distutils-SIG mailing list