Python的easy_install和自定义标头/库位置

时间:2012-08-09 18:34:39

标签: python linux shared-libraries header-files easy-install

我正在尝试使用linux安装adns-python并且必须使用一些特殊选项重新编译adns,所以我似乎无法像往常那样使用easy_install <tarball>

(py26_default)[mpenning@localhost src]$ easy_install adns-python-1.2.1.tar.gz
Processing adns-python-1.2.1.tar.gz
Running adns-python-1.2.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-9cVl4i/adns-python-1.2.1/egg-dist-tmp-vvO8Ms
adnsmodule.c:10:18: error: adns.h: No such file or directory
adnsmodule.c:31: error: expected specifier-qualifier-list before âadns_stateâ

adns.h安装在/opt/adns/include/adns.h下;如何使用adns

的本地安装进行easy_install安装

修改

尝试以下后,我仍然发现ld错误,即使我导出了LD_LIBRARY_PATH ...

(py26_default)[mpenning@localhost src]$ ls /opt/adns/lib/
libadns.a  libadns.so  libadns.so.1  libadns.so.1.2
(py26_default)[mpenning@localhost src]$ export LD_LIBRARY_PATH=/opt/adns/lib
(py26_default)[mpenning@localhost src]$ C_INCLUDE_PATH=/opt/adns/include easy_install ./adns-python-1.2.1.tar.gz
Processing adns-python-1.2.1.tar.gz
Running adns-python-1.2.1/setup.py -q bdist_egg --dist-dir /tmp/easy_install-x68T9f/adns-python-1.2.1/egg-dist-tmp-MpCzMP
/usr/bin/ld: cannot find -ladns
collect2: ld returned 1 exit status
error: Setup script exited with error: command 'gcc' failed with exit status 1
(py26_default)[mpenning@localhost src]$ 

2 个答案:

答案 0 :(得分:3)

LD_LIBRARY_PATH用于在运行时(运行可执行文件时)查找共享库,而不是在链接期间查找。

要构建扩展,请解压缩tarball并运行:

python setup.py build_ext -I/opt/adns/include -L/opt/adns/lib -R/opt/adns/lib

安装:

python setup.py install

您可以在setup.cfg中指定build_ext选项:

[build_ext]
include_dirs=/opt/adns/include
library_dirs=/opt/adns/lib
rpath=/opt/adns/lib

在这种情况下,您可以直接运行easy_install。

答案 1 :(得分:0)

请尝试这样

INCLUDE_PATH=/opt/adns/include easy_install adns-python-1.2.1.tar.gz

如果无效,请尝试使用CPLUS_INCLUDE_PATHC_INCLUDE_PATH

相关问题