[xslt] python bindings of libxslt


I was trying to take a look at libxslts python bindings.

So I installed libxml2-2.4.17 and libxslt1.0.13 from the sources.
I have a python 2.1.1 running (as it came out of the box of my suse linux).

I configured both libxml and libxslt without any specific options.
configure for libxml finds python:
checking for python... (cached) /usr/bin/python
Found Python version 2.1
Then I compiled and installed libxml without seeing any problems.
Then I had a little problem, because my python is installed in /usr/lib
whereas libxml puts it's modules in /usr/local/lib. So I put 
/usr/local/lib/python2.1/site-packages in $PYTHONPATH to make python find 
libxml bindings.

Configuring libxslt then gives
checking for python... (cached) /usr/bin/python
Found Python version 2.1
Found libxml2-python module

Everything seems to compile and install fine, but when I go to
/usr/local/share/doc/libxslt-python-1.0.13/examples and try a
python basic.py
all I get is a
(54 ...share/doc/libxslt-python-1.0.13/examples) python basic.py                Traceback (most recent call last):
  File "basic.py", line 3, in ?
    import libxslt
  File "/usr/local/lib/python2.1/site-packages/libxslt.py", line 40, in ?
    import libxsltmod
ImportError: /usr/local/lib/python2.1/site-packages/libxsltmod.so: undefined symbol: libxml_xmlXPathParserContextPtrWrap

nm shows that the symbol is defined in libxml2mod.so (at least if I
understand the T-flag correct):
(60 ...local/lib/python2.1/site-packages) nm libxml2mod.so | grep libxml_xmlXPathParserContextPtrWrap
00016880 T libxml_xmlXPathParserContextPtrWrap

strace shows that python is reading libxml2.py and libxml2mod.so before
reading libxslt.py and libxsltmod.so.
OTOH libxsltmod.so does not depend on libxml2mod.so:
(67 ...local/lib/python2.1/site-packages) ldd libxsltmod.so 
        libxslt.so.1 => /usr/local/lib/libxslt.so.1 (0x4000f000)
        libm.so.6 => /lib/libm.so.6 (0x40048000)
        libexslt.so.0 => /usr/local/lib/libexslt.so.0 (0x4006a000)
        libxml2.so.2 => /usr/local/lib/libxml2.so.2 (0x40076000)
        libz.so.1 => /lib/libz.so.1 (0x40118000)
        libc.so.6 => /lib/libc.so.6 (0x40128000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x80000000)

The line that finaly makes libxsltmod.so in the build process is
gcc -Wall -g -o .libs/libxsltmod.so -o .libs/libxsltmod.so ./libxslt.o ./types.o
 ./libxslt-py.o -shared -Wl,-soname -Wl,libxsltmod.so  ../libxslt/.libs/libxslt.
so -L/usr/local/lib -lm -lm -lm ../libexslt/.libs/libexslt.so /usr/local/lib/lib
xml2.so -lm -lz -lm -lm  -Wl,--rpath -Wl,/usr/local/lib

So I added /usr/local/lib/python2.1/site-packages/xml2mod.so
and copied the lib from .libs to /usr/local/lib/python/site-packages.
After adding this path to LD_LIBRARY_PATH I was able to run basic.py

But I'm pretty sure that this kind of hacking is not the intended way
of making libxslts python bindings work ;-)
So I'd apreciate if someone could give me a hint, what might have been
wrong in the normal installation.

How is python supposed to resolve dependencies between dynamically linked
c modules?
I guess the problem would not show up, if both modules are statically
linked into python, but I didn't try that.

I hope I included all necessary information. The operating system is
linux (kernel 2.4.16, python version is 2.1.1)

thanks and greetings

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]