15 Answers
15

Thanks to @jessenoller on Twitter I have an answer that fits my needs - you can compile lxml with static dependencies, hence avoiding messing with the libxml2 that ships with OS X. Here's what worked for me:

The 'cd libs/' step fails for me, but it along with the following two wgets seem to be unnecessary as they happen as a side-effect of the 'setup.py build...' step anyway.
–
fuzzymanAug 14 '09 at 17:31

Hmm... it's possible that libs/ directory was created for me the first time I ran "python setup.py build --static-deps" and it failed (because my firewall didn't allow FTP) - I actually pulled the .tar.gz files down via an intermediary server to work around that problem.
–
Simon WillisonAug 15 '09 at 7:19

I had this working fine with Snow Lepoard but after I upgraded to Lion I had to symlink gcc-4.2 to gcc. Running sudo env ARCHFLAGS="-arch i386 -arch x86_64" easy_install lxml was looking for gcc-4.2 instead of gcc.

Failing that the ports version isn't that ancient. You can see the dependencies, some of which had to be updated for my Linux build of lxml.

info py25-lxml
py25-lxml @2.1.5 (python, devel)

lxml is a Pythonic binding for the libxml2 and libxslt libraries. It is unique
in that it combines the speed and feature completeness of these libraries with
the simplicity of a native Python API, mostly compatible but superior to the
well-known ElementTree API.
Homepage: http://codespeak.net/lxml/