PolicyStat / terrarium

Package and ship relocatable python virtualenvs, like a boss.
https://terrarium.readthedocs.io/en/latest
BSD 3-Clause "New" or "Revised" License
171 stars 14 forks source link

Create virtualenv with --no-site-packages? #36

Closed msabramo closed 11 years ago

msabramo commented 11 years ago

It looks like the Terrarium-created virtualenvs include site-packages? Should they not so that they are isolated from the system Python?

marca@marca-mac:~/python/virtualenvs$ cat testenv.requirements
SQLAlchemy==0.8.1
marca@marca-mac:~/python/virtualenvs$ terrarium --target testenv install testenv.requirements
Building new environment
New python executable in /Users/marca/python/virtualenvs/testenv/bin/python
...

marca@marca-mac:~/python/virtualenvs$ testenv/bin/pip freeze
Fabric==1.5.3
PyYAML==3.10
Pygments==1.6
SQLAlchemy==0.8.1
Sphinx==1.1.3
WebOb==1.2.3
argparse==1.2.1
blessings==1.5
coloredlogs==0.3.1
...
kylegibson commented 11 years ago

Hi Marc,

Thanks for the issue.

Part of the process of building a terrarium involves making the virtual environment "relocatable." As a consequence of this process, all of the scripts in bin are updated with relative paths. bin/pip is actually just a python script:

$ ~/foobar 
> less bin/pip
#!/usr/bin/env python2.7
...

The env she-bang causes your shell to use whatever python2.7 is available, in this case, the global one. That is why you are seeing the global packages.

The only ways I know around this issue are:

If this doesn't make any sense, let me know.

msabramo commented 11 years ago

Ah, that makes sense. I forgot that's how relocatable virtualenvs work. Thanks for the explanation!