[lxml-dev] Using, or building, lxml in Windows with Cygwin

David Antliff david.antliff at gmail.com
Tue Jun 16 07:29:13 CEST 2009


Hello,

I am trying to get the Windows lxml egg to work with Cygwin, Python 2.5.2 on
WindowsXP, 32bit. I wasn't able to find a Cygwin package for lxml so I felt
I needed to obtain or build a win32 version of lxml. I want to use the xpath
functionality that lxml provides in python scripts, running in Cygwin.

*** All commands below are issued in a Cygwin bash shell ***

I downloaded lxml-2.2.1-py2.5-win32.egg<http://pypi.python.org/packages/2.5/l/lxml/lxml-2.2.1-py2.5-win32.egg#md5=e7848267af1916a689927bdd1432abb4>from
http://pypi.python.org/pypi/lxml/2.2.1 and placed it in a directory, setting
PYTHONPATH to point here too. However pkg_resources.require() can't find it,
so instead I unzipped it into a directory called 'lxml'. Then I do this:

$ python
Python 2.5.2 (r252:60911, Dec  2 2008, 09:26:14)
[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from lxml import etree
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "lxml/etree.py", line 7, in <module>
    __bootstrap__()
  File "lxml/etree.py", line 6, in __bootstrap__
    imp.load_dynamic(__name__,__file__)
ImportError: Permission denied


Ok, I think I know why this is happening, so I do this:
$ chmod +x lxml/*.pyd
$ python
Python 2.5.2 (r252:60911, Dec  2 2008, 09:26:14)
[GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from lxml import etree
Segmentation fault (core dumped)

Ok, so that didn't work.

The next thing I tried was the instructions found here:
http://www.scribd.com/doc/16158375/LXML-221-documentation in section 23.7 -
"Static linking on Windows".
I downloaded the latest versions of iconv, libxml2, libxslt, zlib and
lxml-2.2.1.tar.gz.  I unpacked them as per the instructions and edited
lxml-2.2.1/setup.py to fix the STATIC_INCLUDE_DIRS and STATIC_LIBRARY_DIRS
to point back to those newly extracted libraries. Now I run:

$ cd lxml-2.2.1
$ python setup.py bdist_wininst --static
Building lxml version 2.2.1.
NOTE: Trying to build without Cython, pre-generated 'src/lxml/lxml.etree.c'
needs to be available.
ERROR: /bin/sh: xslt-config: command not found

** make sure the development packages of libxml2 and libxslt are installed
**

Using build configuration of libxslt
Building against libxml2/libxslt in one of the following directories:
  ..\libxml2-2.7.3.win32\lib
  ..\libxslt-1.1.24.win32\lib
  ..\zlib-1.2.3.win32\lib
  ..\iconv-1.9.2.win32\lib
running bdist_wininst
error: distribution contains extensions and/or C libraries; must be compiled
on a Windows 32 platform

So I figure this is because I'm trying to build inside Cygwin. I tried
inside a cmd.exe window, and it gets a bit further but then complains about
not having VisualC++2003 installed... I tried -c mingw32 but setup.py didn't
understand that option. Seemed like a dead end. I think it might be picking
up my ActiveState Python installation too, rather than the Cygwin one.

I also tried the actual versions of libxml, libxslt etc that the document
actually mentions, same result.

Anyway, my understanding is that all this should be unnecessary - the .egg
should contain everything I need, shouldn't it? But the segmentation fault
at import time is bad.

I'd really like to use lxml in Cygwin if possible, because all the other
options for xpath processing seem very limited. I like the idea of the egg
because I want to be able to deploy my XML-processing python scripts with
the .egg, so that I don't need to install any additional software (such as
Cygwin packages).

Any help would be greatly appreciated, please.

Regards,

-- David.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://codespeak.net/pipermail/lxml-dev/attachments/20090616/9f10b825/attachment.htm 


More information about the lxml-dev mailing list