building matplotlib-0.99.1.1.tar.gz on Mac OS X 10.6.1 (Snow Leopard)

Hello,

With the caveat that I have not closely followed this mail list, I thought I would offer an alternate build method than what seems to be the preferred method for building matplotlib on Mac OS X. I tried to skim through recent mailing list posts to see if anything like this had been done, and did not immediately find anything. Forgive me if I'm repeating!

As of Mac OS X 10.6.1, if you have X11 installed, you can build and use matplotlib without downloading anything else. (Unfortunately I have not yet had the opportunity to try this procedure out on a Leopard system.)

First, I created a new setup.cfg on full auto:

$ diff setup.cfg.template setup.cfg
25,26c25,26
< #pytz = False
< #dateutil = False

ยทยทยท

---
> pytz = auto
> dateutil = auto
53,57c53,57
< #gtk = False
< #gtkagg = False
< #tkagg = False
< #wxagg = False
< #macosx = False
---
> gtk = auto
> gtkagg = auto
> tkagg = auto
> wxagg = auto
> macosx = auto

Then, I altered setupext.py so that the darwin config works like other operating systems. The difference is that I'm telling the script to look in /usr/X11, where freetype and libpng can be found on Mac OS X 10.6.1.

$ diff setupext.py.orig setupext.py
53,54c53,54
< '_darwin' : ['/sw/lib/freetype2', '/sw/lib/freetype219', '/usr/local',
< '/usr', '/sw'],
---
> # '_darwin' : ['/sw/lib/freetype2', '/sw/lib/freetype219', '/usr/local',
> # '/usr', '/sw'],
60c60
< 'darwin' : [],
---
> 'darwin' : ['/usr', '/usr/X11',],

Then, I run:

$ sudo python setupegg.py install

And matplotlib builds as a universal binary and installs an egg into /Library/Python/2.6/site-packages/

The setup process detects the included numpy 1.2.1 and freetype2 (unknown version*), and also detects libpng (unknown version*), Tkinter 67083, Tk 8.5, and Tcl 8.5.

* freetype is 2.3.9; see /usr/X11/include/freetype2/freetype/freetype.h
* libpng is 1.2.35; see /usr/X11/include/libpng12/png.h

On a 64-bit system in the default configuration (like both of mine), there is no 64-bit version of the wxPython libraries to load, and so it is not detected. However, if I do:

$ export VERSIONER_PYTHON_PREFER_32_BIT=yes ### see the python man page

Then the setup process detects wxPython 2.8.8.1.

I filed a bug with Apple about the lack of a 64-bit wxPython library, and it is Apple Problem ID # 7294359, in case anyone cares.

The setup process does not detect Gtk+, Qt(4), or Cairo, because these are not included with Mac OS X (that I know of).

Hope this is helpful!

-Dan Huff

ps -- As an aside, I create & edit ~/.pydistutils.cfg to allow an install for a per-user install as follows:

$ cat ~/.pydistutils.cfg
[install]
install_lib = $HOME/Library/Python/$py_version_short/site-packages
install_scripts = $HOME/usr/local/bin

$ mkdir -p ~/Library/Python/2.6/site-packages
$ python setupegg.py install

This allows for more isolated testing in a sandbox user account.

(end aside)