How to make sure buildout doesn't use the already installed packages?

生来就可爱ヽ(ⅴ<●) 提交于 2020-01-12 18:53:10

问题


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 ?


回答1:


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.




回答2:


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".




回答3:


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



来源:https://stackoverflow.com/questions/4839194/how-to-make-sure-buildout-doesnt-use-the-already-installed-packages

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!