virtualenv question: include just a few site packages

Gelonida N gelonida at gmail.com
Thu Oct 9 11:55:44 EDT 2014


On 10/09/2014 03:19 PM, Jean-Michel Pichavant wrote:
> ----- Original Message -----
>> virtualenv has the switch
>> --system-site-packages (including all system site pacgaes)
>> and the switch
>> --no-site-packages (to expclude all site packages)
>>
>> Does anyone know an easy way to include just a few site-packages?
>> for example (PySide, but not PyQt)
>>
>> The reason I'm asking is following.
>> Some site packages  are sometimes raher huge or sometimes refuse to
>> compile on certain hosts.
>>
>> as these packages are already part of the site packages I'd like to
>> include them.
>>
>> You might wonder why I care whether I have more site packages than I
>> need. As long as I don't import them,  I shouldn't care about it.
>> If I really wanted to replace a version I could use pip install -U.
>>
>> However sometimes I'd like to have a test environment where want to
>> be
>> sure, that no module can find certain other modules. so they should
>> not be visible.
>>
>> at the moment I make some experiments with pyinstaller and the module
>> pythonqtbindings. and there I'd like to be sure that no PuQt files
>> end up in the generated code.
>>
>> The only idea, that I have so far is to
>> run virutalanv with --system-side-packages and to manually remove
>> modules I don't want or to
>> run virtualenv without this switch and to manually add links for site
>> packages, taht I want. both options don't really feel right for me.
>>
>> Is there any other way?
>
> You could build a virtual machine, installing only your VIP modules, and create virtual environment on this virtual machine, using the system site packages.
>

Yeah that's an option.

However I guess in this case it's probably faster to write a script, 
that 'post-processes' the virtualenv and just deletes files / symlinks, 
that are not desired. Definitely not elegant, but probably OK. On the 
other hand a VM migfht help finding out which files to keep.







More information about the Python-list mailing list