Charlie Moad has provided these build notes on the process he uses to build the official universal binary eggs for OS X with statically linked in freetype and libpng. You can download the latest builds from the sourceforge download page

Build instructions for a matplotlib distribution on OSX

Using python-2.5 package from python.org

Getting starting

quaternion:mpl-build cmoad$ pwd
/usr/local/src/mpl-build
quaternion:mpl-build cmoad$ ll
total 11408
-rw-r--r--@ 1 cmoad  staff   1.2M Jul  2 18:06 freetype-2.3.5.tar.bz2
-rw-r--r--@ 1 cmoad  staff   600K Nov  9 07:31 libpng-1.2.23.tar.bz2
-rw-r--r--  1 cmoad  wheel   3.8M Nov 29 21:47 matplotlib-0.91.1.tar.gz

Setup environment for Universal builds of libpng and freetype

quaternion:mpl-build cmoad$ export MACOSX_DEPLOYMENT_TARGET=10.4
quaternion:mpl-build cmoad$ export CFLAGS="-arch i386 -arch ppc -isysroot /Developer/SDKs/MacOSX10.4u.sdk"
quaternion:mpl-build cmoad$ export LDFLAGS="-arch i386 -arch ppc -syslibroot,/Developer/SDKs/MacOSX10.4u.sdk"

Starting with libpng

quaternion:mpl-build cmoad$ tar -xjf libpng-1.2.23.tar.bz2 
quaternion:mpl-build cmoad$ cd libpng-1.2.23
}}

To avoid errors with "-M" flags and Universal builds, pass "--disable-dependency-tracking" to configure

{{{
quaternion:libpng-1.2.23 cmoad$ ./configure --disable-dependency-tracking
quaternion:libpng-1.2.23 cmoad$ make -j3

quaternion:libpng-1.2.23 cmoad$ cp .libs/libpng.a ./

To prove we have a Universal binary

quaternion:libpng-1.2.23 cmoad$ file libpng.a 
libpng.a: Mach-O universal binary with 2 architectures
libpng.a (for architecture i386):       current ar archive random library
libpng.a (for architecture ppc):        current ar archive random library

Next to freetype

quaternion:libpng-1.2.23 cmoad$ cd ../
quaternion:mpl-build cmoad$ tar -xjf freetype-2.3.5.tar.bz2 
quaternion:mpl-build cmoad$ cd freetype-2.3.5
quaternion:freetype-2.3.5 cmoad$ ./configure
quaternion:freetype-2.3.5 cmoad$ make -j3

Copy the freetype static lib to its source root as well

quaternion:freetype-2.3.5 cmoad$ cp objs/.libs/libfreetype.a ./

To prove we have a Universal binary

quaternion:freetype-2.3.5 cmoad$ file libfreetype.a 
libfreetype.a: Mach-O universal binary with 2 architectures
libfreetype.a (for architecture i386):  current ar archive random library
libfreetype.a (for architecture ppc):   current ar archive random library

Finally to matplotlib

quaternion:freetype-2.3.5 cmoad$ cd ../

This OSX package from python.org will build Universal python extensions without our help

quaternion:mpl-build cmoad$ unset MACOSX_DEPLOYMENT_TARGET
quaternion:mpl-build cmoad$ unset CFLAGS 
quaternion:mpl-build cmoad$ unset LDFLAGS

Point gcc to our new Universal builds of libpng and freetype

quaternion:mpl-build cmoad$ export CFLAGS="-arch ppc -arch i386 -I/usr/local/src/mpl-build/libpng-1.2.23 -I/usr/local/src/mpl-build/freetype-2.3.5/include"
quaternion:mpl-build cmoad$ export LDFLAGS="-arch ppc -arch i386 -L/usr/local/src/mpl-build/libpng-1.2.23 -L/usr/local/src/mpl-build/freetype-2.3.5"

Now we are ready to build matplotlib

quaternion:mpl-build cmoad$ tar -xzf matplotlib-0.91.1.tar.gz 
quaternion:mpl-build cmoad$ cd matplotlib-0.91.1

Edit "setupext.py" near line 50, the "basedir" variable. We want to avoid linking in third party libraries. Change:

To:

Matplotlib's detected environment for those interested (I already installed numpy)

quaternion:matplotlib-0.91.1 cmoad$ python setupegg.py 
============================================================================
BUILDING MATPLOTLIB
            matplotlib: 0.91.1
                python: 2.5.1 (r251:54869, Apr 18 2007, 22:08:04)  [GCC
                        4.0.1 (Apple Computer, Inc. build 5367)]
              platform: darwin

REQUIRED DEPENDENCIES
                 numpy: 1.0.4
             freetype2: found, but unknown version (no pkg-config)

OPTIONAL BACKEND DEPENDENCIES
                libpng: found, but unknown version (no pkg-config)
               Tkinter: Tkinter: 50704, Tk: 8.4, Tcl: 8.4
              wxPython: no
                        * wxPython not found
                  Gtk+: no
                        * Building for Gtk+ requires pygtk; you must be able
                        * to "import gtk" in your build/install environment
                    Qt: no
                   Qt4: no
                 Cairo: no

OPTIONAL DATE/TIMEZONE DEPENDENCIES
              datetime: present, version unknown
              dateutil: matplotlib will provide
                  pytz: matplotlib will provide

OPTIONAL USETEX DEPENDENCIES
                dvipng: no
           ghostscript: /bin/sh: gs: command not found
                 latex: no

EXPERIMENTAL CONFIG PACKAGE DEPENDENCIES
             configobj: matplotlib will provide
      enthought.traits: matplotlib will provide

Finally build the matplotlib egg

quaternion:matplotlib-0.91.1 cmoad$ python setupegg.py bdist_egg

# The resulting eggs which should be **cross fingers** 10.3+ compatible
quaternion:matplotlib-0.91.1 cmoad$ ll dist/
total 12184
-rw-r--r--  1 cmoad  wheel   5.9M Nov 29 23:03 matplotlib-0.91.1-py2.5-macosx-10.3-fat.egg

MatplotlibOSXBuildNotes (last edited 2008-01-14 20:08:31 by JohnHunter)