如何确保buildout不使用已安装的软件包?

时间:2022-08-17 20:03:48

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

我正在尝试完全切换到buildout - 但我们的开发环境已经在/ usr / lib / pythonxx /中安装了很多东西

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

如何确保buildout不使用已安装在系统上的库 - 最终没有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 ?

无论如何强制buildout不使用/usr/lib/python2.6中安装的鸡蛋?

3 个解决方案

#1


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

如果你想使用site-pakages或者不使用这两个指令中的一个,你可以告诉buildout:include-site-packages和allowed-eggs-from-site-packages

From buildout documentation:

从buildout文档:

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.

然后,您可以使用include-site-packages = false和exec-sitecustomize = false buildout选项来消除对Python的站点包的访问,而不是分别执行其sitecustomize文件(如果存在)。

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.

或者,您可以使用allowed-eggs-from-site-packages buildout选项作为可能来自站点包的鸡蛋的全局感知白名单。此值默认为“*”,接受所有鸡蛋。

#2


3  

Two ways:

两种方式:

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

    使用最新的1.5.something buildouts:默认情况下,它们不使用系统包。

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

    使用-s标志运行bootstrap命令:python bootstrap.py -s,表示“没有站点包”。

#3


0  

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

我在buildout 1.5之前使用的一个替代方案,它带有从系统python中排除egg的选项

virtualenv

的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:

我们编写了一个virtualenv自定义引导程序来创建环境,获取bootstrap.py并放置一个最小的buildout.cfg,但你可以正常使用virtualenv:

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

瞧,你的建筑与virtualenv隔绝了

#1


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

如果你想使用site-pakages或者不使用这两个指令中的一个,你可以告诉buildout:include-site-packages和allowed-eggs-from-site-packages

From buildout documentation:

从buildout文档:

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.

然后,您可以使用include-site-packages = false和exec-sitecustomize = false buildout选项来消除对Python的站点包的访问,而不是分别执行其sitecustomize文件(如果存在)。

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.

或者,您可以使用allowed-eggs-from-site-packages buildout选项作为可能来自站点包的鸡蛋的全局感知白名单。此值默认为“*”,接受所有鸡蛋。

#2


3  

Two ways:

两种方式:

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

    使用最新的1.5.something buildouts:默认情况下,它们不使用系统包。

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

    使用-s标志运行bootstrap命令:python bootstrap.py -s,表示“没有站点包”。

#3


0  

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

我在buildout 1.5之前使用的一个替代方案,它带有从系统python中排除egg的选项

virtualenv

的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:

我们编写了一个virtualenv自定义引导程序来创建环境,获取bootstrap.py并放置一个最小的buildout.cfg,但你可以正常使用virtualenv:

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

瞧,你的建筑与virtualenv隔绝了