Skip to content

Instantly share code, notes, and snippets.

@flavianmissi
Last active January 24, 2016 10:42
Show Gist options
  • Save flavianmissi/6426108 to your computer and use it in GitHub Desktop.
Save flavianmissi/6426108 to your computer and use it in GitHub Desktop.
Building and installing lxml with pypy2.1.0 and python 2.7.3 (ubuntu 13.04)

Bootstrap

Follow Andrews' post to install PyPy: andrewsmedina.com/2013/07/28/introducao-ao-pypy/

Create a virtualenv (I'm using virtualenvwrapper) with pypy executable:

  $ mkvirtualenv lxml-pypy -p /path/to/bin/pypy

Clone the lxml fork that is using cffi instead of Cython:

  $ git clone https://github.com/amauryfa/lxml.git

Resolving Dependencies

You'll need to install the following packages to build lxml (with both, Python or PyPy):

  $ [sudo] apt-get install libxml2 libxslt1-dev zlib1g-dev

Building lxml

cd into the lxml repository and run:

  $ git checkout origin/cffi
  $ python setup.py build
  $ python setup.py install

Done!

@mattdeboard
Copy link

Hi, sorry for the random help request, but do you have any idea why I might be getting compilation errors running this on Ubuntu 14.04, PyPy 2.6.0?

src/lxml-cffi/__pycache__/_cffi__g65f9f103xa680a747.c: In function ‘_cffi_e__xmlRelaxNGValidErr’:
src/lxml-cffi/__pycache__/_cffi__g65f9f103xa680a747.c:7845:8: error: ‘XML_RELAXNG_OK’ undeclared (first use in this function)
   if ((XML_RELAXNG_OK) > 0 || (long)(XML_RELAXNG_OK) != 0L) {
        ^
src/lxml-cffi/__pycache__/_cffi__g65f9f103xa680a747.c:7845:8: note: each undeclared identifier is reported only once for each function it appears in
src/lxml-cffi/__pycache__/_cffi__g65f9f103xa680a747.c:7855:8: error: ‘XML_RELAXNG_ERR_MEMORY’ undeclared (first use in this function)
   if ((XML_RELAXNG_ERR_MEMORY) <= 0 || (unsigned long)(XML_RELAXNG_ERR_MEMORY) != 1UL) {
        ^
src/lxml-cffi/__pycache__/_cffi__g65f9f103xa680a747.c:7865:8: error: ‘XML_RELAXNG_ERR_TYPE’ undeclared (first use in this function)
   if ((XML_RELAXNG_ERR_TYPE) <= 0 || (unsigned long)(XML_RELAXNG_ERR_TYPE) != 2UL) {

It goes on like this for awhile before Python raises an exception about cc exiting with status code 1.

@ruipacheco
Copy link

Did you install the dependencies?

@msva
Copy link

msva commented Jan 22, 2016

@ruipacheco I've same errors (actually, lot more of them), and I definitelly installed deps.
// although, maybe there is too fresh versions, including gcc

@lopuhin
Copy link

lopuhin commented Jan 24, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment