Re: [xml] python bindings on windows



Stéphane Bidoul kirjutas E, 04.11.2002 kell 12:30:
Hi all,

4. Finally, I applied minor changes to setup.py to use 
the correct path for includes and libraries, as well as to link
with "libxml2" and "libxslt" instead of "xml2" and "xslt",
and remove "m" and "z" from the libs.

I tried to preserve the unix behaviour, and I can post
my changes if someone is interested.

Now, the packaging question.

I would like to use the nice python distutils feature
that creates a windows installer to make a binary distribution
containing both the python bindings and the libxml and libxslt
dlls. The question is where to install the dlls?

I dont, know where Igor's win32 installer puts them,  but I'd guess the
same place would be fine ;)

As for the .pyd, .py, .pyc files, the should preferrably be put under
corresponding python's  site-packages/ directory.

BTW, which version did you build for ?

What compiler did you use ?

Anyway, I'd like to try them, are your python modules available
somewhere ?


Putting them in %SYSTEMROOT%\system32 would probably create
many versioning headaches. A nice place that avoids all
versioning conflicts, is to put them 
in the same place as the libxml2mod.pyd and libxsltmod.pyd
(in python/lib/site-packages, that is). The problem, is that
you end up with the following files in the same place:
libxml2.py, libxml2.dll and libxml2mod.pyd (and the
same for xslt). 

Now when you try "import libxml2", unfortunately, python first 
tries to load libxml2.dll and fails since that one is not a python
extension. The solution I found is to create the following
directory structure in site-packages:

  libxml2.py
  libxmlmods/__init__.py
  libxmlmods/libxml2mod.pyd
  libxmlmods/libxml2.dll

The only change necessary is then to write 
"from libxmlmods import libxml2mod"
instead of "import libxml2mod" in libxml2.py.

This seems to be a nice workaroud for the case when you want to have
many different libxml2.dll's , and should also work when you have
libxml2.dll in %SYSTEMROOT%\system32.

That change is fairly straightforward, and should not break any
existing code since (as I understand it) libxml2mod is normally 
not imported directly. 

You could try to put libxml2mod.pyd in the directory libxml2mod and do
"from libxml2mod import *" in libxml2mod/__init__.py so you don't need
to change  libxml2.py at all.

I find that solution very convenient, because in one 
installer package, I can distribute the python bindings 
together with their private copy of the libxml dlls: 
easy to install and no risk of clashing with 
preinstalled versions.

If there is some interest for such an approach, 
I can post the installer somewhere, so you can give it a try.

I would definitely like to try it.

--------------------
Hannu




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