Thursday, January 15, 2009

Installing Python 2.4 and libxml2 on Mac OS X 10.5 (Leopard) for Plone

I've had quite the struggle with getting libxml2 and related libraries installed on my Mac OS X (10.5 - Leopard) . Thanks to Brent Lambert of enPraxis recommending MacPorts, I have finally managed to stumble my way through the hoops and hurdles to have a successful installation with all the pieces working for developing with Plone on my Mac.

I come from a background of working on and programming websites and think Plone is a fascinating, sophisticated, top-notch solution for content management. I also think it's a great platform for developing web applications, but find the initial learning curve to be almost prohibitively steep. I see the promised land on the other side of the ridge, but am still struggling to get there. Maybe you can relate.

I'm proficient on Unix and with simple shell usage, commands, etc... but I've never fully followed the gory details of compiling libraries and the like. Generally I issue the ./configure, make, sudo make install commands, cross my fingers and hope for the best. I follow-up on any error messages I can decode, but there's still a seemingly black-hole of mystery surrounding the compliation process. At this point I've actually lost track of the number of Python installations on my system (OS X 10.5 seems to come with Python 2.3 and 2.5, the Plone distribution for Mac comes with Python 2.4, I compiled one, found another download, etc...) and I had a similar experience with downloading, compiling and installing libxml2.

Since Zope requires Python 2.4 and Plone is built on Zope, there's a version induced nightmare (well, maybe that's stating it a little strongly, but you get the gist, yes?). The version needs were particularly problematic since Leopard comes with an older version of libxml2 and a newer version of Python, etc...

This is still a bit of a mystery to me, but rather than detail all the things that didn't work, here's what worked for me:
  1. Install Apple's Xcode (required by MacPorts).
  2. Install MacPorts.
  3. Run these commands, roughly in the below order:
sudo port install python24
sudo port install python_select
sudo python_select python24
sudo port install libxml2
sudo port install libxslt
sudo port install py-libxml2
Other commands I ran which may be necessary for Plone:
sudo port install py-xml
sudo port install py-elementtree
sudo port install py-setuptools
sudo port install py-lxml
sudo port install py-pil
I know it's a bit of a shotgun approach and since I had already made a mess of my system I had to issue some relinking to make Python 2.4 the default (ln -sf /opt/local/bin/python2.4 /usr/local/bin/python, for example). A lot of this is voodoo to me. If the commands work, great, if not, I follow up with the erorr messages in google and attempt to piece it all together. I'm not uber-concerned with what side-effects this may have on my system. I just know it now works for me.

I hope this helped!