7

I am trying to switch fully to buildout - but our development environment already has lot of stuff installed in /usr/lib/pythonxx/

How can I make sure that buildout doesn't use the libraries installed on the system already - eventually without virtualenv ?

For example - how to avoid this behavior ? :

> cat buildout.cfg
[buildout]
parts = django

[django]
recipe = zc.recipe.egg
eggs = django
interpreter = django

>bin/django 

>>> import django
>>> django
<module 'django' from '/usr/lib/python2.6/site-packages/django/__init__.pyc'>
>>> 

Is there anyway to force buildout NOT to use the eggs installed in /usr/lib/python2.6 ?

Martin
  • 905
  • 9
  • 19

3 Answers3

9

You can tell buildout if you want to use site-pakages or not with one of these two directives: include-site-packages and allowed-eggs-from-site-packages

From buildout documentation:

You can then use include-site-packages = false and exec-sitecustomize = false buildout options to eliminate access to your Python's site packages and not execute its sitecustomize file, if it exists, respectively.

Alternately, you can use the allowed-eggs-from-site-packages buildout option as a glob-aware whitelist of eggs that may come from site-packages. This value defaults to "*", accepting all eggs.

Ski
  • 14,197
  • 3
  • 54
  • 64
  • Those options only worked for me when I use z3c.recipe.scripts instead of zc.recipe.egg; I'm not sure if this is a result of me doing something wrong, but perhaps it will be useful to someone. – Daniel Feb 14 '12 at 03:51
  • i could only find this critical piece of information on the pypi page for buildout. The docs @ http://www.buildout.org/docs/ don't seem to mention it(either that or the search is broken). Why this isn't the default baffles me. But I'm looking at it as virtualenv on steroids which might not be buildouts full intent. – Tom Willis Jun 13 '12 at 18:17
  • Yes I also find this confusing, the readme at pypi is actually the full documentation and the docs at `buildout.org/docs` covers only few topics. – Ski Jun 14 '12 at 06:51
  • @Skirmantas am also have the same issue some of my python packages I got from dist-packages and others from the directory I created for the project, I set allowed-eggs-from-site-packages = false in buildout.cfg, Still I have the problem. – Jisson Feb 16 '13 at 09:18
3

Two ways:

  • Use the latest 1.5.something buildouts: they don't use the system packages by default.

  • Run the bootstrap command with the -s flag: python bootstrap.py -s, which means "no site packages".

Reinout van Rees
  • 13,486
  • 2
  • 36
  • 68
0

one alternative that i did use before buildout 1.5 that come with options for exclude eggs from your system python was

virtualenv

we write a virtualenv custom bootstrap that create the environment, fetch bootstrap.py and put a minimal buildout.cfg, but you can use virtualenv normally:

cd project virtualenv --no-site-packages ./
wget http://...../bootstrap.py 
touch buildout.cfg
source bin/activate
python bootstrap.py
bin/buildout

and voila, your buildout isolated with a virtualenv

Black Hand
  • 310
  • 2
  • 4