Thursday, February 12, 2009

Static LXML builds

I've built a recipe for building LXML on OSX boxes statically -- w/o dependencies to libxslt and libxml2.

http://pypi.python.org/pypi/z3c.recipe.staticlxml

This works for quite some people -- please report back if it does'nt work for you (and if it works).

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}

Monday, May 19, 2008

lxml on OSX -- again

Hi folks :)

Today, I've again tried to install lxml on OS X. For a project I do for a customer (migrating featurecreep CMS sites to Plone), I use the lxml parser. I get regular segfaults, this time using python 2.4 (I use macport for python 2.4).
I investigated again, and came along this post. The scoop is:
after blood, sweat, and some tears (kidding) this is *all* I needed, it seems:

export CFLAGS="-flat_namespace"

...no static builds libxml2 libs, no buildout recipe. I just set that and ran:

python setup.py bdist_egg
--with-xml2-config=/opt/local/bin/xml2-config
--with-xslt-config=/opt/local/bin/xslt-config

which uses the libxml2 and etc. installed by ports. In fact, as long
as /opt/local/bin is on my path that should work without having to set
paths (i.e. from easy_install). All my tests that were segfaulting
are now passing. This appears to be the exact same behavior I got by
setting DYLD_FORCE_FLAT_NAMESPACE at runtime but without the side
affect of applying itself to anything else running in my shell ;)

so, I'm thinking this is just two lines of code added to cflags() ...

if sys.platform in ('darwin',):
result.append('-flat_namespace')


Well. What can I say. Interesting poinst so far for OS X development:
  • no -rpath supported
  • no static libraries (Yup! No joke)

Sunday, May 18, 2008

Read This Post!

I found this post quite educating.

Thursday, May 15, 2008

Aardvark bookmarklet

Duh.

One should read on, THEN post.

Aardvark for Safari --- sort of

Well, this might be old news for you, but by dragging the "run demo" link on the Aardvark home page to the Safari bookmark bar actually allows you to inject Aardvark to the page your're currently viewing.

I think that's cool and useful :)

incredible stuff

I've just found this incredible stuff on the web. I thought I just might blog about it.

git shelves
import gitshelve

data = gitshelve.open(repository = '/tmp/data.git')

data[key] = "Hello, world!"
Data.Sync()
del data[key]
data.close()

How cool is this? Distributed CMS someone?
Original post here. Git it here,
processing on **javascript**

This guy actually ported the processing language to Javascript.
Thats f***ing awesome!

Friday, May 09, 2008

LXML on OS X (again)

It seems that building lxml on Mac OS X is still a problem. I'm trying to use buildout as in:
[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]
recipe = zc.recipe.egg:custom
egg = lxml
include-dirs = ${buildout:directory}/parts/libxml2/include/libxml2
${buildout:directory}/parts/libxslt/include
library-dirs = ${buildout:directory}/parts/libxml2/lib
${buildout:directory}/parts/libxslt/lib
rpath = ${buildout:directory}/parts/libxml2/lib
${buildout:directory}/parts/libxslt/lib


That fails when buildout tries to build the lxml egg. Looking closely at the error, I discovered that despite pointing it at the libxslt built, it still uses the one found in /usr/lib.

To be more specific: lxml tries to find xslt-config, which is in $BO/parts/libxslt/bin/xslt-config, but of course finds the one in /usr/bin first.

What I'd like to do is to add something like:

# this would be needed but zc.recipe.egg:custom doesn't allow for that
# Doh.
extra_options= --with-xslt-config=${buildout:directory}/parts/libxslt/bin/xslt-config


That option is available in zc.recipe.cmmi, but not in zc.recipe.egg. Looking at custom.py there I sadly found no obvious way to add this as it uses some version of easy_install.

D'oh.

Possible solutions:
  • build egg manually, add to egg cache (yuck-bleah)
  • build manually for OS X, add to own egg server (yuck)
  • roll-my-own recipe (work)