build matplotlib on OSX Lion

A user just replied with some problems he had and made me realize that I’d forgotten that I manually installed a freetype2 lib (which made the earlier build recipe work). If I undo that manual freetype2 installation, then I believe the earlier recipe will work with the following change:

export CFLAGS=’-I/usr/X11/include -I/usr/X11/include/freetype2 -I/usr/X11/include/libpng15’

-Randy

···

Begin forwarded message:

From: Randy Heiland <heiland@…139…>

Subject: build matplotlib on OSX Lion

Date: August 9, 2011 4:45:31 PM EDT

To: matplotlib-users@lists.sourceforge.net

Hi all,

Since I recently got a new machine with a fresh install of OSX Lion, I thought I’d share my building-from-source experience. There seems to be a variety of approaches for doing this that folks have offered up - including installing another Python, installing homebrew (and subsequent pkgs), etc. So I thought I’d add one more - and for all I know this is redundant info.

My approach was the following:

  • use the Python that came with the system:
    Python 2.7.1 (r271:86832, Jun 16 2011, 16:59:05)
    [GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin

  • download matplotlib from git:
    git clone git://github.com/matplotlib/matplotlib.git

cd matplotlib
export CFLAGS=’-I/usr/X11/include/freetype2 -I/usr/X11/include/libpng15’

cd /usr/local/lib
sudo ln -s /usr/X11/lib/libpng15.dylib libpng15.dylib
sudo ln -s /usr/X11/lib/libfreetype.6.dylib libfreetype.dylib

python setup.py build
sudo python setup.py install

-Randy