[xml-bindings]Python bindings in libxml2-2.4.16/libxslt-1.0.12



[Please Cc replies to me as I'm not currently subscribed to these
lists, btw, wasn't sure which was more relevant, so posted to both].

Hi,

I'm having trouble building (and in understand *what* to build) to get
the Python bindings working.

According the instructions on 

http://xmlsoft.org/XSLT/python.html

It says you need to install another tarball (in addition to the
libxml2 and libxslt that I installed, I'm on Slackware so no RPMs will
work here):

  * Otherwise use the libxml2-python module distribution corresponding
    to your installed version of libxml2 and libxslt. Note that to
    install it you will need both libxml2 and libxslt installed and
    run "python setup.py build install" in the module tree.

Here's what I did:

1.  I configured both libxml2 and libxslt with python like so:

$~/src/libxslt-1.0.12$ ./configure --with-python=/net --prefix=/net

Attempted to compile and got the following when I run "make" in the
python subdirectory (of libxslt), I get the following warnings
(although they don't seem to be fatal):

allelea:~/src/libxslt-1.0.12/python$ make
Making all in .
make[1]: Entering directory `/home/alex/src/libxslt-1.0.12/python'
cd . && /net/bin/python generator.py
Found 167 functions in libxslt-api.xml
Found 26 functions in libxslt-python-api.xml
Generated 110 wrapper functions, 81 failed, 2 skipped

Missing type converters:
xsltStackElemPtr:3  xsltStylePreCompPtr:18  pythonObject *:4  xsltTemplatePtr:6  xmlChar*:2  void *:6  xsltDocumentPtr:7  xsltTransformFunction:5  xmlOutputBufferPtr:1  xmlXPathFunction:4  xmlNodeSetPtr:2  xsltDecimalFormatPtr:2  xsltElemPreCompPtr:2  char **:5  xsltCompMatchPtr:3  xsltExtInitFunction:2  xmlXPathCompExprPtr:2  xmlChar **:1  xmlNodePtr *:2  xsltNumberDataPtr:1  xsltPreComputeFunction:1  xsltTopLevelFunction:2 
/bin/sh ../libtool --mode=compile gcc -DHAVE_CONFIG_H -I. -I. -I.. -I/usr/include/python2.1 -I/net/include/python2.1 -I/net/include/libxml2/libxml -I/net/include/libxml2 -I..    -Wall -g -c libxslt.c
mkdir .libs
[...]
creating libxsltmod.so

2. OK, then did "make tests", and things went awry:

cd tests && make tests
make[1]: Entering directory `/home/alex/src/libxslt-1.0.12/python/tests'
-- basic.py
Traceback (most recent call last):
  File "basic.py", line 3, in ?
    import libxslt
  File "/home/alex/src/libxslt-1.0.12/python/libxslt.py", line 2, in ?
    import libxsltmod
ImportError: /home/alex/src/libxslt-1.0.12/python/libxsltmod.so: undefined symbol: libxml_xmlXPathParserContextPtrWrap
-- extfunc.py
Traceback (most recent call last):
  File "extfunc.py", line 5, in ?
    import libxslt
  File "/home/alex/src/libxslt-1.0.12/python/libxslt.py", line 2, in ?
    import libxsltmod
ImportError: /home/alex/src/libxslt-1.0.12/python/libxsltmod.so: undefined symbol: libxml_xmlXPathParserContextPtrWrap
make[1]: [tests] Error 1 (ignored)


3. Pressing on, hoping that this would be fixed in good time, as
   instructed, I tried the tarball in 

ftp://xmlsoft.org/python/

and did a "python setup.py build":

It appears to generate *another* copy of the identical libraries: 

$ ~/src/libxml2-python-2.4.16$ ls build/lib.linux-i686-2.1/libx*
build/lib.linux-i686-2.1/libxml2.py
build/lib.linux-i686-2.1/libxml2mod.so*
build/lib.linux-i686-2.1/libxslt.py
build/lib.linux-i686-2.1/libxsltmod.so*

which have already been generated by libxml2 and libxslt:

$ ~/src/libxslt-1.0.12/python$ ls libxsltmod.so libxslt.py
libxslt.py  libxsltmod.so*

$ ~/src/libxml2-2.4.16/python$ ls libxml2.py libxml2mod.so   
libxml2.py  libxml2mod.so*

4. I then installed this *after* libxml2 and libxslt are installed (I
   had to hack the `setup.py' script considerably because my prefix is
   `/net' not `/usr'):

$ sudo ./setup.py install
Password:
./setup.py:0: SyntaxWarning: name 'xml_files' is assigned to before global declaration
running install
running build
running build_py
not copying libxml2.py (output up-to-date)
not copying libxslt.py (output up-to-date)
running build_ext
skipping 'libxml2mod' extension (up-to-date)
skipping 'libxsltmod' extension (up-to-date)
running install_lib
not copying build/lib.linux-i686-2.1/libxml2.py (output up-to-date)
not copying build/lib.linux-i686-2.1/libxslt.py (output up-to-date)
copying build/lib.linux-i686-2.1/libxml2mod.so -> /net/lib/python2.1/site-packages
copying build/lib.linux-i686-2.1/libxsltmod.so -> /net/lib/python2.1/site-packages
byte-compiling /net/lib/python2.1/site-packages/libxml2.py to libxml2.pyc
byte-compiling /net/lib/python2.1/site-packages/libxslt.py to libxslt.pyc

5. Now when I go back to run the "basic.py" test, nothing works, I get
   a segfault:

$ ~/src/libxslt-1.0.12/python/tests$ gdb python
GNU gdb 5.0
Copyright 2000 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-slackware-linux"...
(gdb) run ./basic.py
Starting program: /net/bin/python ./basic.py
[New Thread 1024 (LWP 25078)]

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 1024 (LWP 25078)]
0x40027b10 in __pthread_mutex_trylock (mutex=0xfa6329eb) at mutex.c:64
64	mutex.c: No such file or directory.
(gdb) bt
#0  0x40027b10 in __pthread_mutex_trylock (mutex=0xfa6329eb) at mutex.c:64
#1  0x400ceda8 in arena_get2 (a_tsd=0x815b748, size=48) at malloc.c:2141
#2  0x400cf0c0 in __libc_malloc (bytes=38) at malloc.c:2714
#3  0x808e0ad in PyString_FromString (str=0x40198f5d "xmlCatalogDump")
    at Objects/stringobject.c:114
#4  0x808b762 in PyDict_SetItemString (v=0x8158a54, 
    key=0x40198f5d "xmlCatalogDump", item=0x8159808)
    at Objects/dictobject.c:1403
#5  0x806a0f2 in Py_InitModule4 (name=0x40198f7a "libxml2mod", 
    methods=0x4019b784, doc=0x0, passthrough=0x0, module_api_version=1010)
    at Python/modsupport.c:57
#6  0x40191046 in initlibxml2mod () at libxml.c:1430
#7  0x40194634 in initlibxsltmod () at libxslt.c:366

[.. repeated output > 5000 times is snipped, must a recursive function
call..]

There seems to be considerable overlap between the code in the python
subdirectories in the libxml2/libxslt and in this
libxml2-python-2.4.16 tarball (which, incidentally doesn't seem to be
a module anywhere in the GNOME CVS).

I can't figure out the relationship between libxml2 and
libxml2-python, is one generated from the other, are they separate
modules?

Confusedly yours,

Alex














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