Long time, too lazy to blog. Don't ask. Moving on, I've been trying to set up my MacBook Pro as a development box for a while. Since the house I'm in is largely using Python, I've set up both virtualenv and virtualenvwrapper with the latest 2.7 Python (Lion comes with 2.7.1, latest as at the time of writing is 2.7.3), pip, distribute and whatnot.
One of the packages I wanted to install is ReportLab. Unfortunately, it kept building without Freetype support, so TrueType support was unavailable. This wasn't acceptable, so I started looking for ways to build it with FreeType support in.
According to
this, I would have to download and build FreeType separately. That would not do (because I was being lazy, plus, I already had FreeType installed by Apple — I'd already tried to run
brew install freetype, and Homebrew warned me that FreeType already comes with Lion in
/usr/X11/include
and
/usr/X11/lib
.
Initially, I tried adding the respective include and library paths in
setup.cfg
. Didn't work. Eventually, after trying seriously to grok the evil that is distutils code, I found that there is a class called
inc_lib_dirs
, and in its implementation of
__call__()
, it checks the platform, and makes a lot of calls to
aDir()
, setting either an include path (first argument uppercase 'I', no quotes) or a library path (first argument uppercase 'L'; again, without the quotes). I simply added new lines for the appropriate include/library, saved and ran
python setup.py build. This worked, so I ran
python setup.py install. Too tired to test with code. Hope it works for you.
Update: This post talks about building PIL on Snow Leopard with FreeType2 support, but the instructions also work for ReportLab. The tl;dr version is:
- download PIL (or ReportLab) source package
- unpack it
- change directory into the package folder
- create a new file called setup_site.py with the contents: FREETYPE_ROOT = "<freetype library path>", "<freetype header path>"
- run python setup.py build (or install)
Following these instructions, I was able to get PIL and ReportLab installed into my virtualenv.