如何强制buildout使用已安装的包

时间:2015-06-19 15:46:51

标签: python buildout

在服务器上,对于磁盘优化,我们不安装C编译器, 这是问题所在:

我想安装'刺激'带有 buildout 2.3.1 的python包, spur正在使用需要C编译器的pycrypto。

为避免编译,我在服务器(Suse 11SP2)上安装了rpm python-pycrypto(python-pycrypto-2.6-31.7.x86_64.rpm)。我可以通过冻结' pip冻结来查看。已安装pycrypto:

pip freeze 

lxml==2.1.2
mod-python==3.3.1
Numeric==24.2
numpy==1.3.0
pycrypto==2.6
pywbem==0.7.0
PyXML==0.8.4

然而,当我开始构建时,它仍然试图使用不存在的C编译器构建pycrypto。

所以我在buildout.cfg中添加了include-site-packages = true和allowed-eggs-from-site-packages = pycrypto,但它们没有被考虑在内。 我也尝试过:

python bootstrap.py --allow-site-packages
bin/buildout

但这也没有帮助。

我可以做些什么来避免buildout编译已经从rpm编译和安装的软件包?

这是buildout.cfg

[buildout]
newest = false
extensions = gp.vcsdevelop
develop-dir = src
parts = eggs tests wsgi
include-site-packages = true
allowed-eggs-from-site-packages = pycrypto

eggs =
    Django==1.4.8
    ordereddict
    ipython==0.13.2
    django-webtest
    django-grappelli<2.5.0
    django-bootstrap3-datetimepicker
    z3c.recipe.usercrontab
    rrdgraphs
    south
    achilterm
    pynag
    pyaml<14
    DjangoDevKit==1.0.3
    Sphinx
    xlwt
    xlrd
    spur

...

和日志:

# bin/buildout
Unused options for buildout: 'allowed-eggs-from-site-packages' 'include-site-packages'.
Installing eggs.
Getting distribution for 'pycrypto!=2.4,>=2.1'.
configure: error: in `/tmp/easy_install-QFXca_/pycrypto-2.6.1':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 2254, in main

  File "/usr/lib64/python2.6/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/usr/lib64/python2.6/distutils/dist.py", line 975, in run_commands
    self.run_command(cmd)
  File "/usr/lib64/python2.6/distutils/dist.py", line 995, in run_command
    cmd_obj.run()
  File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 380, in run

  File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 610, in easy_install

  File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 659, in install_item

  File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 842, in install_eggs

  File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 1070, in build_and_install

  File "build/bdist.linux-x86_64/egg/setuptools/command/easy_install.py", line 1056, in run_setup

  File "build/bdist.linux-x86_64/egg/setuptools/sandbox.py", line 240, in run_setup
  File "/usr/lib64/python2.6/contextlib.py", line 34, in __exit__
    self.gen.throw(type, value, traceback)
  File "build/bdist.linux-x86_64/egg/setuptools/sandbox.py", line 193, in setup_context
  File "/usr/lib64/python2.6/contextlib.py", line 34, in __exit__
    self.gen.throw(type, value, traceback)
  File "build/bdist.linux-x86_64/egg/setuptools/sandbox.py", line 164, in save_modules
  File "build/bdist.linux-x86_64/egg/setuptools/sandbox.py", line 139, in resume
  File "build/bdist.linux-x86_64/egg/setuptools/sandbox.py", line 152, in save_modules
  File "build/bdist.linux-x86_64/egg/setuptools/sandbox.py", line 193, in setup_context
  File "build/bdist.linux-x86_64/egg/setuptools/sandbox.py", line 237, in run_setup
  File "build/bdist.linux-x86_64/egg/setuptools/sandbox.py", line 267, in run
  File "build/bdist.linux-x86_64/egg/setuptools/sandbox.py", line 236, in runner
  File "build/bdist.linux-x86_64/egg/setuptools/sandbox.py", line 46, in _execfile
  File "/tmp/easy_install-QFXca_/pycrypto-2.6.1/setup.py", line 456, in <module>
  File "/usr/lib64/python2.6/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/usr/lib64/python2.6/distutils/dist.py", line 975, in run_commands
    self.run_command(cmd)
  File "/usr/lib64/python2.6/distutils/dist.py", line 995, in run_command
    cmd_obj.run()
  File "build/bdist.linux-x86_64/egg/setuptools/command/bdist_egg.py", line 160, in run
  File "build/bdist.linux-x86_64/egg/setuptools/command/bdist_egg.py", line 146, in call_command
  File "/usr/lib64/python2.6/distutils/cmd.py", line 333, in run_command
    self.distribution.run_command(command)
  File "/usr/lib64/python2.6/distutils/dist.py", line 995, in run_command
    cmd_obj.run()
  File "build/bdist.linux-x86_64/egg/setuptools/command/install_lib.py", line 10, in run
  File "/usr/lib64/python2.6/distutils/command/install_lib.py", line 112, in build
    self.run_command('build_ext')
  File "/usr/lib64/python2.6/distutils/cmd.py", line 333, in run_command
    self.distribution.run_command(command)
  File "/usr/lib64/python2.6/distutils/dist.py", line 995, in run_command
    cmd_obj.run()
  File "/tmp/easy_install-QFXca_/pycrypto-2.6.1/setup.py", line 251, in run
  File "/usr/lib64/python2.6/distutils/cmd.py", line 333, in run_command
    self.distribution.run_command(command)
  File "/usr/lib64/python2.6/distutils/dist.py", line 995, in run_command
    cmd_obj.run()
  File "/tmp/easy_install-QFXca_/pycrypto-2.6.1/setup.py", line 278, in run
RuntimeError: autoconf error
An error occurred when trying to install pycrypto 2.6.1. Look above this message for any errors that were output by easy_install.
While:
  Installing eggs.
  Getting distribution for 'pycrypto!=2.4,>=2.1'.
Error: Couldn't install: pycrypto 2.6.1

2 个答案:

答案 0 :(得分:4)

我找到了解决方法:

我刚刚在egg-egg目录中创建了一个egg-link文件:

$ cat develop-eggs/pycrypto.egg-link 
/usr/lib64/python2.6/site-packages

答案 1 :(得分:0)

我没有证据证明zc.buildout&gt; 1.7.1支持include-site-packages,也不支持allowed-eggs-from-site-packages

在我的本地计算机上,我搜索了以下zc.buildout版本中提到的功能:

  • zc.buildout-1.4.4-py2.7.egg
  • zc.buildout-1.6.3-py2.7.egg
  • zc.buildout-1.7.1-py2.7.egg
  • zc.buildout-2.0.0-py2.7.egg
  • zc.buildout-2.0.1- py2.7.egg
  • zc.buildout-2.1.0-py2.7.egg
  • zc.buildout-2.2.0-py2.7.egg
  • zc.buildout-2.2.1- py2.7.egg
  • zc.buildout-2.2.3-py2.7.egg
  • zc.buildout-2.2.4-py2.7.egg
  • zc.buildout-2.2.5-py2.7.egg
  • zc.buildout-2.3.0-py2.7.egg
  • zc.buildout-2.3.1-py2.7.egg

https://pypi.python.org/pypi/zc.buildout/1.7.1上查看自述文件。这些功能是在zc.buildout 1.5.0附近引入的。支持这些功能的最后一个版本是1.7.1。

他们使用zc.buildout 2.0.0进行了某种重新启动......

引用changlog,版本2.0.0:

  

这是一个向后不兼容的buildout版本,它试图纠正buildout 1中的错误。

     

Buildout不再试图提供与系统Python安装的完全或部分隔离。如果你想要隔离,可以使用buildout和virtualenv,或者使用干净的Python构建开始。

在您的情况下,这意味着,如果您想使用这些功能,则需要使用zc.buildout 1.7.1

同样重要的是,不可能同时使用这两个选项。使用allowed-eggs-from-site-packages (only specific packages)include-site-packages

我假设你正在使用boostrap.py版本1:http://downloads.buildout.org/1/bootstrap.py

此版本不支持' - allow-site-packages'选项,因为它打算与zc.buildout 1.x一起使用,它处理这种情况(或至少1.5.x)。

嗯,在这次建队历史的短暂旅行之后,我想以下两点可以解决你的问题:

然后python bootstrap.py --allow-site-packages按预期工作。