Commit 0fea6f45 authored by Daniel Veillard's avatar Daniel Veillard
Browse files

added the 'usual' setup.py to allow building a libxml2-python module based

* python/README python/generator.py python/libxml.c python/setup.py:
  added the 'usual' setup.py to allow building a libxml2-python
  module based on the same code. The initialization is however
  different the 2 .so files fo libxml2 and libxslt are identical and
  they entry point initialize both libraries. this is done to avoid
  some possible nasty problem since the Python don't merge the maps
  of all shared modules.
Daniel
parent fcbfa2d9
Fri Feb 22 23:44:57 CET 2002 Daniel Veillard <daniel@veillard.com>
* python/README python/generator.py python/libxml.c python/setup.py:
added the 'usual' setup.py to allow building a libxml2-python
module based on the same code. The initialization is however
different the 2 .so files fo libxml2 and libxslt are identical and
they entry point initialize both libraries. this is done to avoid
some possible nasty problem since the Python don't merge the maps
of all shared modules.
Wed Feb 20 23:16:08 CET 2002 Daniel Veillard <daniel@veillard.com>
* parser.c: fixed a push/encoding bug reported by Michael
......
Module libxml2-python
=====================
This is the libxml2 python module, providing access to the
libxml2 and libxslt (if available) libraries. For general
informationss on those XML and XSLT libraries check their
web pages at :
http://xmlsoft.org/
and
http://xmlsoft.org/XSLT/
The latest version of the sources for this module and the
associated libraries can be found at:
ftp://xmlsoft.org/
Binaries packages of the libxml2 and libxslt libraries can
be found either on the FTP site for Linux, from external
sources linked from the web pages, or as part of your set of
packages provided with your operating system.
NOTE:
this module distribution is not the primary distribution
of the libxml2 and libxslt Python binding code, but as
the Python way of packaging those for non-Linux systems.
The main sources are the libxml2 and libxslt tar.gz found on
the site. One side effect is that the official RPM packages for
those modules are not generated from the libxml2-python
distributions but as part of the normal RPM packaging of
those two libraries.
The RPM packages can be found at:
http://rpmfind.net/linux/rpm2html/search.php?query=libxml2-python
http://rpmfind.net/linux/rpm2html/search.php?query=libxslt-python
Daniel Veillard
This diff is collapsed.
......@@ -4,6 +4,9 @@
* entry points where an automatically generated stub is either
* unpractical or would not match cleanly the Python model.
*
* If compiled with MERGED_MODULES, the entry point will be used to
* initialize both the libxml2 and the libxslt wrappers
*
* See Copyright for the status of this software.
*
* daniel@veillard.com
......@@ -1418,9 +1421,16 @@ static PyMethodDef libxmlMethods[] = {
{ NULL }
};
#ifdef MERGED_MODULES
extern void initlibxml2mod(void);
#endif
void initlibxml2mod(void) {
PyObject *m;
m = Py_InitModule("libxml2mod", libxmlMethods);
libxml_xmlErrorInitialize();
#ifdef MERGED_MODULES
initlibxsltmod();
#endif
}
#!/usr/bin/python -u
#
# Setup script for libxml2 and libxslt if found
#
import sys, os
from distutils.core import setup, Extension
def missing(file):
if os.access(file, os.R_OK) == 0:
return 1
return 0
xml_files = ["libxml2-api.xml", "libxml2-python-api.xml",
"libxml.c", "libxml.py", "libxml_wrap.h", "types.c",
"xmlgenerator.py", "README", "TODO"]
xslt_files = ["libxslt-api.xml", "libxslt-python-api.xml",
"libxslt.c", "libxsl.py", "libxslt_wrap.h",
"xsltgenerator.py"]
if missing("libxml2-py.c") or missing("libxml2.py"):
try:
try:
import xmlgenerator
except:
import generator
except:
print "failed to find and generate stubs for libxml2, aborting ..."
print sys.exc_type, sys.exc_value
sys.exit(1)
head = open("libxml.py", "r")
generated = open("libxml2class.py", "r")
result = open("libxml2.py", "w")
for line in head.readlines():
result.write(line)
for line in generated.readlines():
result.write(line)
head.close()
generated.close()
result.close()
with_xslt=0
if missing("libxslt-py.c") or missing("libxslt.py"):
if missing("xsltgenerator.py") or missing("libxslt-api.xml"):
print "libxslt stub generator not found, libxslt not built"
else:
try:
import xsltgenerator
except:
print "failed to generate stubs for libxslt, aborting ..."
print sys.exc_type, sys.exc_value
else:
head = open("libxsl.py", "r")
generated = open("libxsltclass.py", "r")
result = open("libxslt.py", "w")
for line in head.readlines():
result.write(line)
for line in generated.readlines():
result.write(line)
head.close()
generated.close()
result.close()
with_xslt=1
else:
with_xslt=1
descr = "libxml2 package"
modules = [ 'libxml2' ]
c_files = ['libxml2-py.c', 'libxml.c', 'types.c' ]
includes= ["/usr/include/libxml2"]
libs = ["xml2", "m", "z"]
macros = []
if with_xslt == 1:
descr = "libxml2 and libxslt package"
#
# We are gonna build 2 identical shared libs with merge initializing
# both libxml2mod and libxsltmod
#
c_files = c_files + ['libxslt-py.c', 'libxslt.c']
libs.insert(0, 'xslt')
includes.append("/usr/include/libxslt")
modules.append('libxslt')
macros.append(('MERGED_MODULES', '1'))
extens=[Extension('libxml2mod', c_files, include_dirs=includes,
libraries=libs, define_macros=macros)]
if with_xslt == 1:
extens.append(Extension('libxsltmod', c_files, include_dirs=includes,
libraries=libs))
if missing("MANIFEST"):
global xml_files
manifest = open("MANIFEST", "w")
manifest.write("setup.py\n")
for file in xml_files:
manifest.write(file + "\n")
if with_xslt == 1:
for file in xslt_files:
manifest.write(file + "\n")
manifest.close()
setup (name = "libxml2-python",
version = "2.4.16",
description = descr,
author = "Daniel Veillard",
author_email = "veillard@redhat.com",
url = "http://xmlsoft.org/python.html",
licence="MIT Licence",
py_modules=modules,
ext_modules=extens,
)
sys.exit(0)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment