how to install pycairo for python 3 on Ubuntu 10.04

隐身守侯 提交于 2019-12-10 14:30:04

问题


i am trying to install pycairo 1.10.0 for use with my custom-build python 3.1. however,

sudo /flower/bin/easy_install-3.1 pycairo

fails with

XXX@XXXX:/adventures$ sudo /flower/bin/easy_install-3.1 pycairo
install_dir /flower/lib/python3.1/site-packages/
Searching for pycairo
Reading http://pypi.python.org/simple/pycairo/
Reading http://cairographics.org/pycairo
Best match: pycairo 1.10.0
Downloading http://cairographics.org/releases/pycairo-1.10.0.tar.bz2
Processing pycairo-1.10.0.tar.bz2
error: Couldn't find a setup script in /tmp/easy_install-zeG9HB/pycairo-1.10.0.tar.bz2

and indeed, there is no setup.py in the said download; instead, the INSTALL says:

Install Procedure
-----------------
$ ./waf --help     # shows available waf options
$ ./waf configure  # use --prefix and --libdir if necessary
                   # --prefix=/usr --libdir=/usr/lib64  for Fedora 64-bit
$ ./waf build
$ ./waf install

Use
$ python3 ./waf ...
if you have python2 and python3 installed, and the default is python 2.


Testing
-------
See test/README

i understand that as telling me that i should

sudo /flower/bin/python3.1 ./waf configure --prefix=/flower/pycairo/

or similar; however, this leads to the following error:

  ./options()
Setting top to                           : /tmp/pycairo-1.10.0 
Setting out to                           : /tmp/pycairo-1.10.0/build_directory 
  ./configure()
Checking for 'gcc' (c compiler)          : ok 
Checking for program python              : /usr/bin/python 
python executable '/usr/bin/python' different from sys.executable '/flower/bin/python3.1'
Checking for python version              : (2, 6, 5, 'final', 0) 
The python version is too old, expecting (3, 1, 0)

so i went down into the source code; there is seemingly no way to tell this waf thingie that the targetted python version is simply the one it runs on itself, so i fumbled around and got as far as this:

Checking for 'gcc' (c compiler)          : ok 
Checking for program python              : /usr/bin/python 
#############293 /flower/bin/python3.1
Checking for python version              : (3, 1, 2, 'final', 0) 
Checking for library python3.1 in LIBDIR : yes 
Checking for program python3.1-config    : not found 
Checking for program python-config-3.1   : not found 
Checking for header Python.h             : Could not find the python development headers 
Checking for []                          : not found 
The configuration failed

i do in fact have a file /flower/bin/python3.1-config so i don't get it. the python code that does all this is rather hard to handle.

any suggestions how to go on? is there a *.deb or similar ready for pycairo + python 3? couldn't find any.


回答1:


By looking at the python.py file in that subdir I decided to try setting an environment var before executing the waf thru python3:
export PYTHON="python3"
And then the install mysteriously succeeded...




回答2:


I'm using Ubuntu Karmic, but installing with python2.7 compiled from source, so this is a work around I found in my case. I though it might be helpful, but please use caution.

I found some discussion threads that has similar installation problems here

Although it's not the same python version, there are some flags which you can set for waf.

I got past that Python.h part after using the following command

LDFLAGS="-lm -ldl -lutil" ./waf configure

As I have compiled from source python2.7, I need to reroute the paths with CFLAGS. The final command looks like this:

CFLAGS="-l/usr/local/include/python2.7 -l/usr/local/bin" LDFLAGS="-lm -ldl -lutil" ./waf configure

I have no idea how the LDFLAGS work, so use with caution.

Alternatively (dangerous method), if you don't want to set the CFLAGS, I did do some symbolic-re-linking in the /local/bin of python to my python2.7, same with python-config to python2.7-config (if you installed from package manager, you might not need to do this)




回答3:


This is clearly a bug in the pycairo installer, where it tries to figure out where the Python exe is (when what it should do is to simply use the Python exe that it is run with).

I tried to find it, but this code is using its own completely custom build system (it's not onvious why) and the code is laid out in a very weird way, astonishingly with major parts of the code hidden(!) in a directory called .waf3-1.6.4-e3c1e08604b18a10567cfcd2d02eb6e6 and written in some of the most unreadable Python code I've ever seen. As such it would take me hours to understand this code and help you with what probably is a trivial bug.

If you really need this library I suggest you contact the author and ask him nicely if he can fix the bug.



来源:https://stackoverflow.com/questions/6232529/how-to-install-pycairo-for-python-3-on-ubuntu-10-04

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!