blahg

computers are hard, let's go shopping

Installing PyCairo on a Mac

Installing Cairo through MacPorts is a bit tricky. If you’ve got X11 installed, you have some of its dependencies installed, but not installed through MacPorts. This leads to a barrage of error messages of the form
Error: Target com.apple.activate returned: Image error: foo already exists and does not belong to a registered port. Unable to activate port bar.
I wish I knew the proper way to resolve this, but so far I didn’t have any trouble after resolving it the lazy way: Just remove foo and let MacPorts put it back. Scaredycats could also mv foo foo.bak, but this gets old quickly. One more thing to watch out for, if foo is just a dependency of something else, is that after getting this stumbling block out of the way, you should explicitly do port install foo again; I’ve found that just calling port with whatever you actually want to install tends to skip this step.

Fontconfig needed some more work, as it said: “ftheader.h: No such file or directory
This is a bit puzzling when you actually do have FreeType 2 installed, but it’s easily resolved in this case:
ln -s /opt/local/include/freetype2/freetype /opt/local/include/freetype

This finally got gcc into gear, and a few short coffee breaks later, sudo port install cairo +quartz +atsui had finally succeeded. And with Cairo in place, PyCairo installed quickly and exactly as described in the accompanying INSTALL file.

Now, on with the excellent Cairo Tutorial for Python Programmers, which is actually a good introduction to Cairo for all kinds of Programmers.