These instructions are geared for building a binary installer for matplotlib on Mac OS X 10.4 that will run on 10.3.9 and later. Technically these instructions should also work on a machine running 10.5 or 10.6, but in practice I find that the resulting package cannot be used on 10.3.9 and 10.4 (I have no idea why).
If all you want to do is build matplotlib for yourself, on Mac OS X 10.6 or newer, then you need not install any extra libraries. Install XCode and the python you want to use, then jump to Install Python Packages, and skip bdist_mkpg.
Note: every line that begins with $ is intended to be typed into Terminal (without the leading $; it simply represents the Terminal's prompt).
Install Python from python.org. Using this python will make your matplotlib installer maximally compatible with various versions of Mac OS X.
Install Xcode. If building for MacOS X 10.3.9 and later then be sure to install the 10.3 SDK. You must be a registered Apple Developer to download XCode, but registration is free.
For a version of matplotlib that runs on MacOS X 10.3.9 and later, you must use gcc 4.0.1. XCode installs several versions of gcc in /usr/bin and /usr/bin/gcc is a symlink to one of them. Fix the simlink if necessary so that it points to gcc 4.0.1.
$ export MACOSX_DEPLOYMENT_TARGET=10.3
Unless otherwise noted, all packages are installed as follows:
$ env CFLAGS="-O -g -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc" \ LDFLAGS="-arch i386 -arch ppc" ./configure --disable-dependency-tracking
Note: some packages do not recognize the option --disable-dependency-tracking. If it is rejected then try again without it.
$ make $ make check $ sudo make install
When you are done installing all these unix libraries, do not forget to delete dynamic libraries (as step listed below).
Install zlib (a.k.a. libz). A version is already included with MacOS X 10.4 and later, but not 10.3.9. In any case, it is probably better to provide a modern version.
Install freetype. Version 2.3.12 works fine. Do not use the broken version that Apple includes with X11.
To make a package the libraries you just installed must be linked in statically. Thus you must delete (or move aside) the dynamic libraries. Assuming you took my advice to create a special /usr/local for this job, the following works:
$ sudo rm /usr/local/lib/*.dylib # verify that the remaining libraries are universal $ file /usr/local/lib/*.a
Matplotlib requires numpy.
If you want WXAgg support you must install wxPython. I recommend the most recent stable release (2.8.x at this writing). The 2.9 series is a development branch and is best avoided unless you want to be a beta tester. Warning: if you modified /usr/local then you must install wxPython again, even if it is already installed, since wxPython puts some components in /usr/local.
Install setuptools. Download it, unpack it and type:
$ python setup.py build $ python setup.py install
Install bdist_mpkg, preferably using pip or easy_install, since those will install the prerequisite packages.
backendto TkAgg (because it is standard and available out of the box). Users who prefer WxAgg must install wxPython and should make a matplotlibrc file that specifies WxAgg as the preferred backend. Look for the line starting with #backend, uncomment it and set it to TkAgg:
backend = TkAgg
## Date/timezone support, uncomment the next three lines for pytz, dateutil and six and set them True. This will make the resulting binary install those additional packages (overwriting any existing versions). If you don't make this change then users will have to install their own pytz, dateutil and six.
## Date/timezone support: pytz = True dateutil = True six = True
To create a double-clickable installer package that you and others can use to install matplotlib:
Run Terminal and cd to the top level of the matplotlib source directory:
or you want to run a bdist_mpkg for a particular version of python you can be explicit, for example:
The binary installer will be inside subdirectory
If you wish to have an egg distribution, you can build it as follows:
First edit setupcfg.py and comment out the two lines for pytz and dateutil so that they are not built (they should be a dependency of the egg rather than included in the egg).
Then build the egg as follows:
$ python setupegg.py bdist_egg
The egg file will be inside subdirectory
Install matplotlib using your new installer. cd out of the matplotlib source directory and run the tests:
$ python -c "import matplotlib as m ; m.test(verbosity=1)"
Save your /usr/local in case you wish to do future builds, and move your normal /usr/local back into place (if you had one):
$ sudo mv /usr/local /usr/local-static $ sudo mv /usr/local-disabled /usr/local
Before distributing the binary installer I recommend a few cleanup steps:
Many thanks to Charlie Moad and mpsuzuki for help with installation instructions and to Sandro Tosi and Derek Homeier for testing instructions.
Russell Owen University of Washington PO Box 351580 Seattle, WA 98195-1580 rowen u washington edu @ . .