Python的easy_install和自定义标头/库位置 [英] Python's easy_install and custom header/library location

查看:91
本文介绍了Python的easy_install和自定义标头/库位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Linux安装 adns-python ,并且必须重新编译<一个带有一些特殊选项的href ="http://www.chiark.greenend.org.uk/~ian/adns/" rel ="nofollow"> adns ,所以我似乎无法使用像往常一样easy_install <tarball>

I am trying to install adns-python using linux and had to recompile adns with some special options, so I can't seem to use easy_install <tarball> as I normally would

(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安装?

adns.h is installed under /opt/adns/include/adns.h; how can I make easy_install install with a local installation of adns?

编辑

经过下面的尝试,即使我导出了LD_LIBRARY_PATH ...,我仍然发现ld错误.

After the attempt below, I still find an ld error, even though I exported 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]$ 

推荐答案

LD_LIBRARY_PATH用于在运行时(运行可执行文件时)而不是在链接过程中查找共享库.

LD_LIBRARY_PATH is used to find a shared library at runtime (when an executable is run), not during linking.

要构建扩展,请打开压缩包并运行:

To build the extension, unpack the tarball and run:

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选项:

You could specify build_ext options in setup.cfg:

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

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

in this case you could run easy_install directly.

这篇关于Python的easy_install和自定义标头/库位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆