[XML-SIG] Availability of libxml2 and libxslt Python bindings

M.-A. Lemburg mal@lemburg.com
Fri, 22 Feb 2002 11:08:37 +0100

Daniel Veillard wrote:
> On Thu, Feb 21, 2002 at 07:02:20PM +0100, M.-A. Lemburg wrote:
> > Daniel Veillard wrote:
> > >  This seems related to something like:
> > >    module A need shared lib l1
> > >    module B need module A and shared lib l2
> > >    shared lib l2 depends on a symbol from l1
> >
> > This is a bad thing for portability. You should never have
> > shared libs depend on each other -- dynamic linking will simply
> > screw up completely...
>   Come'on zlib is shared and used for example by libpng. And if your
> graphic library need it you would have to have a special version
> of libpng statically compiled against zlib, nahhh you cannot impose
> this, on any platform !

If the dependencies are listed statically in the shared lib,
you don't have a problem -- the dynamic linker will then
load the lib on demand. However, Python loads module using
linker APIs, so the linking process is deferred and subject
to the linker options used for module import.

The problem is that Python does not use the RTLD_GLOBAL
option per default (I don't remember why, but do remember
there were some problems with making it the default). As
a result the symbols from the loaded DLLs are not made 
available to the process and neither to any other DLL
which might need them.

Now this is how it works on Linux... not sure about other

Note that Fred's trick with dynamically setting the
dlopen() flags only work on Python 2.2 and above.

> > Probably in the dynamic linker of the OS. Also, on some
> > platforms each DLL uses it's own heap for memory
> > allocation.
> >
> > Why not simply make l1 and l2 a single shared lib ?
>   No I'm not gonna ship with library statically linked inside my
> shared library. The linker should be fixed instead.

You tell this Microsoft ;-)

Seriously, I think that Fred's second proposal (combining
the Python wrapper modules, rather than the libs) solves
this best. And it should work on all platforms and with all
Python versions.

Marc-Andre Lemburg
CEO eGenix.com Software GmbH
Company & Consulting:                           http://www.egenix.com/
Python Software:                   http://www.egenix.com/files/python/