Thursday, June 05, 2008

lxml on OSX -- solved

Hi guys. I've been investigating building lxml on OSX for quite some time now.

Here's the scoop so far:
  • I want to use buildout
  • I want NOT to use Apple's libraries (libxml, libxslt)
  • On OSX there's no "--rpath" option available, thus there's no way to tell an executable on link time where to look for dynamic libraries
  • This is disgusting (do we have 2008 or what?)
Ok, that's what I've come up with. Note the z3c.recipe.egg, it allows for arguments to the setup script, which the original zc.recipe.egg does not. The version 2.0.6 of lxml has a fix for OSX in, which allows to do away with DYLD_LIBRARY_PATH, BUT you need a DYLD_FORCE_FLAT_NAMESPACE=1. Don't ask. I have no idea.
[lxml]
parts=
libxml2
libxslt
lxml-download
lxml-build

[libxml2]
recipe = zc.recipe.cmmi
url = http://ftp.gnome.org/pub/GNOME/sources/libxml2/2.6/libxml2-2.6.26.tar.gz
extra_options = --without-python

[libxslt]
recipe = zc.recipe.cmmi
url = http://ftp.gnome.org/pub/GNOME/sources/libxslt/1.1/libxslt-1.1.16.tar.bz2
extra_options = --with-libxml-prefix=${buildout:directory}/parts/libxml2/
--without-python

[lxml-download]
recipe = plone.recipe.distros
urls = http://codespeak.net/lxml/lxml-2.0.6.tgz
version-suffix-packages = lxml-2.0.6.tgz

[lxml-build]
recipe = z3c.recipe.egg:setup
setup = ${lxml-download:location}/lxml
args =
clean
build
bdist_egg
--with-xslt-config=${buildout:directory}/parts/libxslt/bin/xslt-config
develop = true

You use it like:

[buildout]
extends=
lxml.cfg
parts=
${lxml:parts}
eggs=
${lxml:eggs}