Skip to content

Instantly share code, notes, and snippets.

@hmml
Last active December 10, 2020 05:39
Show Gist options
  • Save hmml/4647895 to your computer and use it in GitHub Desktop.
Save hmml/4647895 to your computer and use it in GitHub Desktop.
Install lxml on Mac OS X 10.7 (Python 2.7.1)
#!/bin/bash
#
# Install lxml on Mac OS X 10.7. It might work for 10.8 as well.
#
LXML_LIB=libxml2-2.9.0
LXML_ARCHIVE=libxml2-2.9.0.tar.gz
# Start install, it's going to fail...
STATIC_DEPS=true pip install lxml
# Patch sources...
pushd /private/tmp/pip-build/lxml/libs
tar -zxvf $LXML_ARCHIVE
rm $LXML_ARCHIVE
pushd $LXML_LIB
curl https://git.gnome.org/browse/libxml2/patch/threads.c?id=3f6cfbd1d38d0634a2ddcb9a0a13e1b5a2195a5e | patch
popd
tar -zcvf $LXML_ARCHIVE $LXML_LIB
rm -rf $LXML_LIB
popd
# Build again...
STATIC_DEPS=true pip install --no-download lxml
# Check if package is usable...
echo "import lxml; from lxml import etree" | python -
if [ $? -ne 0 ]
then
echo "LXML failed to install."
else
echo "LXML ready to use."
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment