Posts Tagged x86_64

Install python lxml 64 bit on OSX 10.5

This is one of those note-to-self style posts again.
I’m not really clear on why this has to be so damned complicated: every time I mess with lxml on OSX it costs me half a day!

The second-last time I had to do this, I actually stripped everything but the 32 bit executable out of apache to force it into 32 bit mode, so that I wouldn’t have to compile a 64bit lxml! (and yes, that’s just stupid, don’t do it).

Anyway, this is how I managed to get it to compile this time:

mkdir /tmp/lxml-build
cd /tmp/lxml-build
curl -O http://codespeak.net/lxml/lxml-2.3.tgz
tar -zxf lxml-2.3.tgz
cd lxml-2.3
mkdir libs
cd libs
curl -O ftp://xmlsoft.org/libxml2/libxml2-2.7.3.tar.gz
curl -O ftp://xmlsoft.org/libxml2/libxslt-1.1.24.tar.gz
cd ..

Here we need to modify the build code for lxml. (Yes, I know this shouldn’t be the case, but the arch is hardcoded in there for 10.5 as i386, and we simply have to change it).
Open the file buildlibxml.py, and, at around line 284, find the following lines:

            if minor_version < 6:
                env.update({
                    'CFLAGS' : "-arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -O2",
                    'LDFLAGS' : "-arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk",
                    'MACOSX_DEPLOYMENT_TARGET' : "10.3"
                    })
            else:

… changing them to the following …

            if minor_version < 5:
                env.update({
                    'CFLAGS' : "-arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -O2",
                    'LDFLAGS' : "-arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk",
                    'MACOSX_DEPLOYMENT_TARGET' : "10.3"
                    })
            elif minor_version < 6:
                env.update({
                    'CFLAGS' : "-arch x86_64 -arch i386 -O2",
                    'LDFLAGS' : "-arch x86_64 -arch i386",
                    'MACOSX_DEPLOYMENT_TARGET' : "10.5"
                    })
            else:

i.e. we change the first case to 10.4 and earlier, and add a case for 10.5 (the minor_version < 6 stuff).
We can now continue with the compilation as follows:

ARCHFLAGS='-arch x86_64' python setup.py build --static-deps --libxml2-version=2.7.3 --libxslt-version=1.1.24
ARCHFLAGS='-arch x86_64' sudo python setup.py install

And that should be it.

If something goes wrong, do a make clean before changing the build options. And note that you’ll probably need to restart apache (sudo apachectl restart) to pick up on changes.

References: here, here, and here.

, , , , ,

1 Comment

css.php