how to install pycairo for python 3 on Ubuntu 10.04
Asked Answered
O

3

5

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.

Ostrander answered 3/6, 2011 at 20:49 Comment(0)
H
10

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...

Headstand answered 17/7, 2011 at 9:15 Comment(2)
This is the one tip on the entire internet that helped me configure the thing correctly. But now the goddamn build fails! Have any tips for that?Rapids
This helped me tremendously on OSX, thanks! Now, if I could only fix the next problem (Could not find the program pkg-config)... EDIT : sudo port install pkgconfig was my saviorCrissie
H
4

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)

Houseboy answered 25/7, 2011 at 4:51 Comment(0)
M
2

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.

Moorfowl answered 4/6, 2011 at 9:37 Comment(3)
thanks a lot for your response. i was afraid to say this as i easily go off, but this is my n-th experience with (py)cairo and it's just true: the whole project is inscrutable, and the build system is abysmal. there is a list, but it's only on sourceforge and run by mailman. when you click on "report a bug", you have to first enter a login that you don't have. it almost looks like being inaccessible on purpose. i'll just have to leave it at that i guess. sad because in itself cairo is very promising, i believe firefox uses it to render web pages.Ostrander
@flow: I tried a simplified build procedure that "should" have worked, but then it can't find a config.h which I don't know where it is supposed to come from.Moorfowl
@flow: That said, it seems that PyCairo itself has reasonable codepractices, it's the "waf" install system that is utterly insane. I think it would be fairly simple for somebody who understands the code to switch to distutils or something else that is sane. But most likely the author is a part of the distutils-hating crowd, so you would have to fork it.Moorfowl

© 2022 - 2024 — McMap. All rights reserved.