doesn't find libxml2 headers automatically

Bug #144471 reported by Marius Gedminas
2
Affects Status Importance Assigned to Milestone
lxml
Fix Released
Low
Unassigned

Bug Description

On Debian/Ubuntu libxml2-dev installs the headers into /usr/include/libxml2. In order to build lxml you need to pass an extra parameter to setup.py, as documented in http://codespeak.net/lxml/build.html:

   python setup.py build_ext -i -I /usr/include/libxml2

This solution doesn't work when setuptools tries to automatically install lxml as a dependency for something else.

On Linux, the standard way of figuring out the flags to pass to the C compiler is to use pkg-config:

  $ pkg-config --cflags libxml-2.0
  -I/usr/include/libxml2

It would help if lxml's setup.py would use this to determine the necessary build flags automatically.

Revision history for this message
Wichert Akkerman (wichert) wrote :

pkg-config is not Linux-specific at all, it works on at least all POSIX systems and possibly on Windows as well.

Revision history for this message
scoder (scoder) wrote :

lxml's setup.py (or rather setupinfo.py) currently uses "xslt-config", which should be part of "libxslt1-dev". Could you check what that returns on your system?

I'm on Ubuntu Feisty, and it nicely prints "-I/usr/include/libxml2" for me when asked for the "--cflags".

The problem with pkg-config is that it needs to be installed - and it's *not* currently a standard requirement for building lxml.

Revision history for this message
Marius Gedminas (mgedmin) wrote :

Apparently I did not have libxslt1-dev installed. With it installed, setuptools nicely installs lxml as a dependency.

I wonder if there's a way to get a better error message in this case. I saw hundreds of gcc errors beginning with a failure to find libxml.h, and didn't realize I needed libxslt1-dev too.

Would it be sane to abort setup.py if xslt-config is not available? Is xslt-config available on all platforms (including Windows), or just on POSIX ones?

Revision history for this message
scoder (scoder) wrote :

Funny, you were actually referring to build.txt, where it says:

"""
If you get errors about missing header files (e.g., ``libxml/xmlversion.h``)
then you need to make sure the development packages of libxml2 and libxslt are
properly installed. If this doesn't help, you may have to add the location of
the header files to the include path like::
"""

I think we should emit a warning if xslt-config can't be found.

scoder (scoder)
Changed in lxml:
importance: Undecided → Low
status: New → Fix Committed
scoder (scoder)
Changed in lxml:
status: Fix Committed → Fix Released
Revision history for this message
thet (thet) wrote :

i also run into problems when installing lxml from pypi via a buildout.
i run ubuntu intrepid ibex.

after checking around i found that i had to install following packages:
libxml2-dev
libxslt1-dev

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.