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

Stefan Behnel stefan_ml at behnel.de
Wed Jun 24 06:41:22 CEST 2009


Hi,

David Antliff wrote:
> I must admit I don't understand how setup.py, setupinfo.py and
> distutils all fits together.  By watching the output of 'python
> setup.py build --static-deps' it's fairly clear to me what is needed
> to fix each step, but I can't work out where one sets extra CFLAGS or
> LDFLAGS in setup.py so that I can continue the process beyond each
> error.

You can pass them externally, as in

	CFLAGS="..." LDFLAGS="..." python setup.py --static-deps


> What would also help is if I knew what command I was meant to be
> using. The documentation suggests all sorts of options and I'm really
> not sure what I'm doing. Here's what I want to end up with:
>   - a statically compiled python 'egg' of lxml that I can simply
> distribute with a python script and use in Cygwin.
> 
> Here's what I currently have:
>  - lxml-2.2.1 tar.gz unpacked
>  - Cygwin *without* libxml2 or libxslt installed (I don't want my
> users to have to install these via Cygwin setup.exe).
>  - gcc, ld, etc are all present

Fair enough, should be doable.


> As per a previous email, I tried:
> $ python setup.py build --static-deps
> 
> But this has problems finding libiconv. You suggested I could
> use-liconv to fix this, but I can't work out where to actually put
> this in setup.py or setupinfo.py.
> 
> $ ls /usr/lib/libic*
> /usr/lib/libiconv.a  /usr/lib/libiconv.dll.a  /usr/lib/libiconv.la
>
> However that's on my own machine - it turns out that nobody else has
> Cygwin's libiconv installed, so I'd like to *statically* link in
> libiconv too. Dynamically linking won't work in my case.

You can try passing

	LDFLAGS=/usr/lib/libiconv.a

to setup.py. Not sure if that works, but it may.

If the above doesn't work, you can take a look at buildlibxml.py. The
function at the end does the library build. Adding your /usr/lib/libiconv.a
to the "static_binaries" list at the end should make it work.

Does that help?

Stefan



More information about the lxml-dev mailing list