使用buildout安装Python c扩展

时间:2012-04-04 22:20:40

标签: python dependency-management buildout

我正在研究的项目需要avro,这需要python-snappy,这需要snappy。我无法想出正确的构建咒语来实际让所有东西一起工作。

以下buildout.cfg已成功构建,但它会将avro安装到 develop-eggs ,并且尝试引用它的任何其他内容(例如在[test]部分中)都会尝试构建再次失败。

buildout.cfg

[buildout]
eggs-directory = eggs
extensions =
    buildout.dumppickedversions
eggs =
    avro
    httplib2
    pyramid
parts =
    avro
    test
    mongodb

[snappy]
# Dependency for avro
recipe = zc.recipe.cmmi
url = http://snappy.googlecode.com/files/snappy-1.0.5.tar.gz

[avro]
recipe = zc.recipe.egg:custom
egg = avro
include-dirs = ${snappy:location}/include
library-dirs = ${snappy:location}/lib

[test]
recipe = pbp.recipe.noserunner
script = runtests
eggs =
    ${buildout:eggs}
    pbp.recipe.noserunner
    WebTest

[mongodb]
recipe = rod.recipe.mongodb
base-url = http://downloads.mongodb.org
version = 2.0.4
darwin-32bit-url = ${mongodb:base-url}/osx/mongodb-osx-i386-${mongodb:version}.tgz
darwin-64bit-url = ${mongodb:base-url}/osx/mongodb-osx-x86_64-${mongodb:version}.tgz
linux2-32bit-url = ${mongodb:base-url}/linux/mongodb-linux-i686-${mongodb:version}.tgz
linux2-64bit-url = ${mongodb:base-url}/linux/mongodb-linux-x86_64-${mongodb:version}.tgz
logpath=${buildout:parts-directory}/mongodb/log
dbpath=${buildout:parts-directory}/mongodb/data
master=true
update=true

输出

Uninstalling avro.
Updating snappy.
Installing avro.
zip_safe flag not set; analyzing archive contents...
Installing test.
Getting distribution for 'python-snappy'.
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
snappymodule.cc:28:20: error: Python.h: No such file or directory
snappymodule.cc:31:22: error: snappy-c.h: No such file or directory
snappymodule.cc:36: error: ISO C++ forbids declaration of ‘PyObject’ with no type
snappymodule.cc:36: error: expected ‘;’ before ‘*’ token
snappymodule.cc:54: error: expected initializer before ‘*’ token
snappymodule.cc:59: error: expected initializer before ‘*’ token
snappymodule.cc:43: warning: ‘_state’ defined but not used
error: Setup script exited with error: command 'gcc' failed with exit status 1
An error occurred when trying to install python-snappy 0.4. Look above this message for any errors that were output by easy_install.
While:
  Installing test.
  Getting distribution for 'python-snappy'.
Error: Couldn't install: python-snappy 0.4

使用buildout处理扩展依赖项是否有直接的方法?我该怎么办?

1 个答案:

答案 0 :(得分:4)

此错误通常表示缺少开发库,可以通过以下方式解决:

  

$ aptitude install python-devel

换句话说,它似乎与buildout无关。