Farm Development

Compiling Python 2.5 on Mac OS X 10.6 (Snow Leopard)

The Mac dev community has outgrown Python 2.5 it seems but you might still need it if, say, you work on a Google App Engine project. I recently set up a fresh new Snow Leopard machine and really didn't want to eff it up with Macports. I like Macports but it leaks dynamic libraries here and there and this screwed me on my last machine. Instead I've had good luck with Homebrew (so far) but I couldn't find a Python 2.5 recipe anywhere. Snow Leopard ships with a version of Python 2.5 but I ran into some trouble with it as soon as I tried using virtualenv. Apple usually messes up Python in some way so I figured I'd just compile one. Since I couldn't find anything succinct while searching online here are my notes.

All the kind folks who use Macports have patched the hell out of Python 2.5 so I took a trial and error approach: apply patches, compile, make, make test. When things failed I'd go back and apply some more patches. You have to watch out though because Macports does this odd thing where they patch in __PREFIX__ then replace it later with the Macports root path. I ended up only needing a few patches (I think) so here's what to apply. Get the patches from svn:

mkdir ~/tmp/macports-py25
cd ~/tmp/macports-py25
svn co

Download Python 2.5.5, cd into the source, and apply these:

cd ~/src/Python-2.5.5
patch -p0 -r . < ~/tmp/macports-py25/python25/files/patch-configure-badcflags.diff
patch -p0 -r . < ~/tmp/macports-py25/python25/files/patch-64bit.diff
patch -p0 -r . < ~/tmp/macports-py25/python25/files/patch-Modules-posixmodule.c.diff
patch -p0 -r . < ~/tmp/macports-py25/python25/files/
patch -p0 -r . < ~/tmp/macports-py25/python25/files/patch-FSIORefNum.diff

Compile and run the tests (they take a long time)

./configure --prefix=/usr/local/python2.5.5 \
  --with-universal-archs="64-bit" \
  CFLAGS="-arch x86_64" LDFLAGS="-arch x86_64"
make test
sudo make install

Now bask in anticlimactic glory that you still have to use Python 2.5 for something!

Note: HTML tags will be stripped. Hit enter twice for a new paragraph.

Recent Projects

  • JSTestNet

    Like botnet but for JS tests in CI.

  • Nose Nicedots

    Nose plugin that prints nicer dots.

  • Fudge

    Mock objects for testing.

  • Fixture

    Loading and referencing test data.

  • NoseJS

    Nose plugin that runs JavaScript tests for a Python project.

  • Wikir

    converts reST to various Wiki formats.