views:

747

answers:

2

I am trying to install the pycairo (Python bindings for the cairo graphics library) under OSX.

I started with

easy_install pycairo

and got:

Requested 'cairo >= 1.8.8' but version of cairo is 1.0.4

error: Setup script exited with Error: cairo >= 1.8.8 not found

So I went to cairo's site and downloaded the latest package (1.8.8) of cairo, and also the latest package of something called pixman (both source packages -- couldn't find osx binaries)

unzipped both, each in own directory. for pixman, the regular ./configure ; make ; sudo make install worked just find for cairo, ./configure seemed to work, but make failed with:

In file included from cairo-analysis-surface.c:37:
cairoint.h:71:20: error: pixman.h: No such file or directory

What am I doing wrong?

And why do I have to struggle so much to get a software library to work on an os that "just works"? Why isn't darwin more like linux?

+2  A: 

Ok. I solved it. Putting solution here for future reference, it might help someone.

Basically, the whole ports/fink system is a bit messed up, and osx doesn't really play nice with the linux-y world.

So, the steps I needed to install pycairo on OSX were:

  • download the latest source versions of pixman, cairo, pycairo
  • extract everything. Then:

    cd PIXMAN_DIR ; ./configure ; make ; sudo make install cd CAIRO_DIR ; cp PIXMAN_DIR/pixman/*.h . ; ./configure ; make ; sudo make install cd PYCAYRO_DIR; locate cairo.pc

hopefully, several locations are returned. choose the most likely one (one with newest cairo). For me it was "/opt/local/lib/pkgconfig/cairo.pc" and do:

export PKG_CONFIG_PATH=/opt/local/lib/pkgconfig/

after this, still in PYCAIRO_DIR, do:

 python setup.py install

This should do it...

Yoav
I think you have problems because you are mixing macports fink and your own code together - use one of these only ;) effecitively each of these is equivalent to the Linix's own packaging system.The reason I say this is that /opt/local/bin would be from Macports and not your own code which by default would be /usr/local/bin
Mark
A: 

On Mac OS you can have multiple Python versions installed. You can have even more if you decide to install Python via Fink or MacPorts. When you compile libraries from the source, you should make sure they point to the correct installation.

I currently have Python 2.5.1 and Python 2.6.4 installed on my machine, which I can call via python2.5 and python respectively. They live in two different folders: /System/Library/Frameworks/Python.framework/Versions/2.5and /Library/Frameworks/Python.framework/Versions/2.6

I was running into a similar problem when compiling pycairo 1.8.8 from the tarball. The INSTALL file in this case is your friend, as it contains the correct instructions to avoid potential version conflicts. You basically need to specify the correct prefix so that the package will be installed in the correct folder.

$ python -c "import sys; print sys.prefix"
  # make a note of the python prefix
$ ./configure --prefix=[python_prefix]
$ make
$ make install       # may require superuser access

Running these instructions with python2.5 and python you will be able to correctly install pycairo for both versions (or for any version installed via MacPorts / Fink).

radrat