[lxml-dev] setupinfo.py that downloads/builds libxml2/libxslt

Ian Bicking ianb at colorstudy.com
Tue Nov 4 23:01:24 CET 2008


I've attached a version of setupinfo.py that will download and build 
libxml2 and libxslt.  There are some problems with the script, but 
hopefully this is a start.

If you give the build option --build-libxml2xslt then it will download 
the packages and build them, and set the options to use the xml2-config 
and xslt-config scripts.  I also made it always use --static if you do 
this.  I'm not sure if that's a good idea, but if they aren't built 
statically then I'm not sure where to install the libraries... though I 
guess they could be installed in some subdirectory of the lxml package? 
  That would be fine, unless there were problems if those libraries were 
then moved around (as they are often during the installation process), 
it might mean that the linker won't find them...?  Also adding files to 
the installation process means some more work.  (It just occurred to 
me... do I have to run "make; make install" for those libraries if it is 
a static build, or would ./configure be sufficient?)

The script will download the newest versions of these libraries, or you 
can give a specific version with --libxml2-version/--libxslt-version. 
Also BUILD_LIBXML2XSLT=true, LIBXML2_VERSION, and LIBXSLT_VERSION 
environmental variables work for these settings.  Maybe there can also 
be a fallback to archives distributed directly with lxml?  The tarballs 
are about 8Mb for the two of them.  Or I suppose just some more flags to 
point to existing source code or tarballs.

The biggest problem is that I'm not sure at all where to put this stuff 
in the setup.py build process.  Right now the options to setup() include 
information about the built versions of these libraries, but simply 
calling "python setup.py" should not cause those libraries to be built. 
  (Right now if you use --build-libxml2xslt it will build those 
libraries at setupinfo/setup.py import time.)  This is the biggest 
problem I see with this at the moment.

Lastly, I'm having problems building lxml trunk right now, with this error:

> cythoning src/lxml/lxml.etree.pyx to src/lxml/lxml.etree.c
> 
> Error converting Pyrex file to C:
> ------------------------------------------------------------
> ...
>     cdef readonly object localname
>     cdef readonly object namespace
>     def __init__(self, text_or_uri_or_element, tag=None):
>         if not _isString(text_or_uri_or_element):
>             if isinstance(text_or_uri_or_element, _Element):
>                 text_or_uri_or_element = (<_Element>text_or_uri_or_element).tag
>                                                   ^
> ------------------------------------------------------------
> 
> /home/ianb/src/lxml/src/lxml/lxml.etree.pyx:259:51: Declarator should be empty

But I got this working with the last lxml release, so that's fine.


-- 
Ian Bicking : ianb at colorstudy.com : http://blog.ianbicking.org
-------------- next part --------------
A non-text attachment was scrubbed...
Name: setupinfo.py
Type: text/x-python
Size: 16333 bytes
Desc: not available
Url : http://codespeak.net/pipermail/lxml-dev/attachments/20081104/567f120e/attachment.py 


More information about the lxml-dev mailing list