waf构建系统找不到python库

时间:2013-10-29 10:24:11

标签: python build waf pycairo

我正在尝试为python3构建pycairo-1.0并获得错误的输出

root@blackenedsun:/home/blackenedsun/Downloads/pycairo-1.10.0# ./waf configure --prefix=/usr 
  ./options()
Setting top to                           : /home/blackenedsun/Downloads/pycairo-1.10.0 
Setting out to                           : /home/blackenedsun/Downloads/pycairo-1.10.0/build_directory 
  ./configure()
Checking for 'gcc' (c compiler)          : ok 
Checking for program python              : /usr/local/bin/python
Checking for python version              : (3, 3, 2, 'final', 0)
Checking for library python3.3 in LIBDIR : not found 
Checking for library python3.3 in python_LIBPL : not found 
Checking for library python3.3 in $prefix/libs : not found 
Checking for library python3.3m in LIBDIR      : yes 
Checking for program python3.3-config          : /usr/bin/python3.3-config 
command ['/usr/local/bin/python', '/usr/bin/python3.3-config', '--includes'] returned 1
root@blackenedsun:/home/blackenedsun/Downloads/pycairo-1.10.0# 

如何才能正确找到python3.3库?

2 个答案:

答案 0 :(得分:2)

我遇到了与python 3.4相同的问题。

这是因为waf试图用python执行python3.4-config而python3.4-config是shell脚本。

事实上,单独启动python3.4-config非常有效。

    [dusserm@l92-ci-e pycairo-1.10.0]$ python3 /Produits/publics/x86_64.Linux.RH6/python/3.4.1/bin/python3.4-config --includes
      File "/Produits/publics/x86_64.Linux.RH6/python/3.4.1/bin/python3.4-config", line 7
        echo "Usage: $0 --prefix|--exec-prefix|--includes|--libs|--cflags|--ldflags|--extension-suffix|--help|--abiflags|--configdir"
                                                                                                                                    ^
    SyntaxError: invalid syntax
    [dusserm@l92-ci-e pycairo-1.10.0]$ /Produits/publics/x86_64.Linux.RH6/python/3.4.1/bin/python3.4-config --includes
    -I/nfs/nfs/Produits/publics/x86_64.Linux.RH6/python/3.4.1/include/python3.4m -I/nfs/nfs/Produits/publics/x86_64.Linux.RH6/python/3.4.1/include/python3.4m

问题来自waf没有正确使用python3.X-config。

我找到的解决方法是直接修改waf脚本解压缩的隐藏目录(在我的例子中是.waf3-1.6.4-e3c1e08604b18a10567cfcd2d02eb6e6)。 转到这个目录,更改文件waflib / Tools / python.py,直接调用python3.X-config而不用python。

--- waflib/Tools/python.py.old  2014-08-01 14:36:23.750613874 +0000
+++ waflib/Tools/python.py      2014-08-01 14:36:38.359627761 +0000
@@ -169,7 +169,7 @@
                conf.find_program('python-config-%s'%num,var='PYTHON_CONFIG',mandatory=False)
        includes=[]
        if conf.env.PYTHON_CONFIG:
-               for incstr in conf.cmd_and_log(conf.env.PYTHON+[conf.env.PYTHON_CONFIG,'--includes']).strip().split():
+               for incstr in conf.cmd_and_log([conf.env.PYTHON_CONFIG,'--includes']).strip().split():
                        if(incstr.startswith('-I')or incstr.startswith('/I')):
                                incstr=incstr[2:]
                        if incstr not in includes:

答案 1 :(得分:1)

我遇到了同样的问题。我通过添加系统变量来修复:
[' /usr/local/bin/python3.4' ;,' /usr/local/bin/python3.4-config', ' - 包括']返回1

export PYTHON_CONFIG="/usr/local/lib/python3.4/config-3.4m/python-config.py"