1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-07-29 11:41:22 +03:00

apply patch from Martin fixing python whitespaces following previous

* python/generator.py python/setup.py: apply patch from Martin fixing
  python whitespaces
* NEWS: following previous commit rebuilt now in UTF-8
Daniel

svn path=/trunk/; revision=3746
This commit is contained in:
Daniel Veillard
2008-06-03 16:08:54 +00:00
parent 25a1ce9134
commit 39801e572a
4 changed files with 645 additions and 397 deletions

View File

@ -1,3 +1,9 @@
Tue Jun 3 18:07:13 CEST 2008 Daniel Veillard <daniel@veillard.com>
* python/generator.py python/setup.py: apply patch from Martin fixing
python whitespaces
* NEWS: following previous commit rebuilt now in UTF-8
Mon Jun 2 17:39:42 CEST 2008 Daniel Veillard <daniel@veillard.com> Mon Jun 2 17:39:42 CEST 2008 Daniel Veillard <daniel@veillard.com>
* ChangeLog: patch from Hans de Goede to switch the file to UTF-8 * ChangeLog: patch from Hans de Goede to switch the file to UTF-8

38
NEWS
View File

@ -95,9 +95,9 @@ http://svn.gnome.org/viewcvs/libxml2/trunk/
flag fix (Richard Jones), regexp interpretation of \, flag fix (Richard Jones), regexp interpretation of \,
htmlCreateDocParserCtxt (Jean-Daniel Dupas), configure.in htmlCreateDocParserCtxt (Jean-Daniel Dupas), configure.in
typo (Bjorn Reese), entity content failure, xmlListAppend() fix typo (Bjorn Reese), entity content failure, xmlListAppend() fix
(Georges-Andr<EFBFBD> Silber), XPath number serialization (William Brack), (Georges-André Silber), XPath number serialization (William Brack),
nanohttp gzipped stream fix (William Brack and Alex Cornejo), nanohttp gzipped stream fix (William Brack and Alex Cornejo),
xmlCharEncFirstLine typo (Mark Rowe), uri bug (Fran<EFBFBD>ois Delyon), xmlCharEncFirstLine typo (Mark Rowe), uri bug (François Delyon),
XPath string value of PI nodes (William Brack), XPath node set XPath string value of PI nodes (William Brack), XPath node set
sorting bugs (William Brack), avoid outputting namespace decl sorting bugs (William Brack), avoid outputting namespace decl
dups in the writer (Rob Richards), xmlCtxtReset bug, UTF-8 encoding dups in the writer (Rob Richards), xmlCtxtReset bug, UTF-8 encoding
@ -105,7 +105,7 @@ http://svn.gnome.org/viewcvs/libxml2/trunk/
workaround wrong file: URIs, htmlNodeDumpFormatOutput on attributes, workaround wrong file: URIs, htmlNodeDumpFormatOutput on attributes,
invalid character in attribute detection bug, big comments before invalid character in attribute detection bug, big comments before
internal subset streaming bug, HTML parsing of attributes with : in internal subset streaming bug, HTML parsing of attributes with : in
the name, IDness of name in HTML (Dagfinn I. Manns<EFBFBD>ker) the name, IDness of name in HTML (Dagfinn I. Mannsåker)
- Improvement: keep URI query parts in raw form (Richard Jones), - Improvement: keep URI query parts in raw form (Richard Jones),
embed tag support in HTML (Michael Day) embed tag support in HTML (Michael Day)
@ -120,7 +120,7 @@ http://svn.gnome.org/viewcvs/libxml2/trunk/
(Steven Rainwater), user data propagation in XInclude (Michael Day), (Steven Rainwater), user data propagation in XInclude (Michael Day),
standalone and XML decl detection (Michael Day), Python id ouptut standalone and XML decl detection (Michael Day), Python id ouptut
for some id, fix the big python string memory leak, URI parsing fixes for some id, fix the big python string memory leak, URI parsing fixes
(St<EFBFBD>phane Bidoul and William), long comments parsing bug (William), (Stéphane Bidoul and William), long comments parsing bug (William),
concurrent threads initialization (Ted Phelps), invalid char concurrent threads initialization (Ted Phelps), invalid char
in text XInclude (William), XPath memory leak (William), tab in in text XInclude (William), XPath memory leak (William), tab in
python problems (Andreas Hanke), XPath node comparison error python problems (Andreas Hanke), XPath node comparison error
@ -130,7 +130,7 @@ http://svn.gnome.org/viewcvs/libxml2/trunk/
min occurs of 0 (William), HTML script/style parsing (Mike Day) min occurs of 0 (William), HTML script/style parsing (Mike Day)
- Improvement: make xmlTextReaderSetup() public - Improvement: make xmlTextReaderSetup() public
- Compilation and postability: fix a missing include problem (William), - Compilation and postability: fix a missing include problem (William),
__ss_familly on AIX again (Bj<EFBFBD>rn Wiberg), compilation without zlib __ss_familly on AIX again (Björn Wiberg), compilation without zlib
(Michael Day), catalog patch for Win32 (Christian Ehrlicher), (Michael Day), catalog patch for Win32 (Christian Ehrlicher),
Windows CE fixes (Andreas Stricke) Windows CE fixes (Andreas Stricke)
- Various CVS to SVN infrastructure changes - Various CVS to SVN infrastructure changes
@ -277,7 +277,7 @@ Do not use or package 2.6.25
2.6.22: Sep 12 2005: 2.6.22: Sep 12 2005:
- build fixes: compile without schematron (St<EFBFBD>phane Bidoul) - build fixes: compile without schematron (Stéphane Bidoul)
- bug fixes: xmlDebugDumpNode on namespace node (Oleg Paraschenko)i, - bug fixes: xmlDebugDumpNode on namespace node (Oleg Paraschenko)i,
CDATA push parser bug, xmlElemDump problem with XHTML1 doc, CDATA push parser bug, xmlElemDump problem with XHTML1 doc,
XML_FEATURE_xxx clash with expat headers renamed XML_WITH_xxx, fix some XML_FEATURE_xxx clash with expat headers renamed XML_WITH_xxx, fix some
@ -550,7 +550,7 @@ Do not use or package 2.6.25
streaming problem (Steve Ball), DTD serialization problem (William), streaming problem (Steve Ball), DTD serialization problem (William),
libxml.m4 fixes (Mike Hommey), do not provide destructors as methods on libxml.m4 fixes (Mike Hommey), do not provide destructors as methods on
Python classes, xmlReader buffer bug, Python bindings memory interfaces Python classes, xmlReader buffer bug, Python bindings memory interfaces
improvement (with St<EFBFBD>phane Bidoul), Fixed the push parser to be back to improvement (with Stéphane Bidoul), Fixed the push parser to be back to
synchronous behaviour. synchronous behaviour.
- improvement: custom per-thread I/O enhancement (Rob Richards), register - improvement: custom per-thread I/O enhancement (Rob Richards), register
namespace in debug shell (Stefano Debenedetti), Python based regression namespace in debug shell (Stefano Debenedetti), Python based regression
@ -676,8 +676,8 @@ Do not use or package 2.6.25
callbacks order for XPath callbacks (Frederic Peters) callbacks order for XPath callbacks (Frederic Peters)
- Documentation: python scripts (William Brack), xslt stylesheets (John - Documentation: python scripts (William Brack), xslt stylesheets (John
Fleck), doc (Sven Zimmerman), I/O example. Fleck), doc (Sven Zimmerman), I/O example.
- Python bindings: fixes (William), enum support (St<EFBFBD>phane Bidoul), - Python bindings: fixes (William), enum support (Stéphane Bidoul),
structured error reporting (St<EFBFBD>phane Bidoul) structured error reporting (Stéphane Bidoul)
- XInclude: various fixes for conformance, problem related to dictionnary - XInclude: various fixes for conformance, problem related to dictionnary
references (William & me), recursion (William) references (William & me), recursion (William)
- xmlWriter: indentation (Lucas Brasilino), memory leaks (Alfred - xmlWriter: indentation (Lucas Brasilino), memory leaks (Alfred
@ -807,7 +807,7 @@ Do not use or package 2.6.25
and charset information if available. and charset information if available.
- Relax-NG: bug fixes including the one reported by Martijn Faassen and - Relax-NG: bug fixes including the one reported by Martijn Faassen and
zeroOrMore, better error reporting. zeroOrMore, better error reporting.
- Python bindings (St<EFBFBD>phane Bidoul), never use stdout for errors - Python bindings (Stéphane Bidoul), never use stdout for errors
output output
- Portability: all the headers have macros for export and calling - Portability: all the headers have macros for export and calling
convention definitions (Igor Zlatkovic), VMS update (Craig A. Berry), convention definitions (Igor Zlatkovic), VMS update (Craig A. Berry),
@ -888,11 +888,11 @@ A bugfixes only release - Windows Makefiles (William Brack)
- portability: DJGPP (MsDos) , OpenVMS (Craig A. Berry) - portability: DJGPP (MsDos) , OpenVMS (Craig A. Berry)
- William Brack fixed multithreading lock problems - William Brack fixed multithreading lock problems
- IPv6 patch for FTP and HTTP accesses (Archana Shah/Wipro) - IPv6 patch for FTP and HTTP accesses (Archana Shah/Wipro)
- Windows fixes (Igor Zlatkovic, Eric Zurcher), threading (St<EFBFBD>phane - Windows fixes (Igor Zlatkovic, Eric Zurcher), threading (Stéphane
Bidoul) Bidoul)
- A few W3C Schemas Structure improvements - A few W3C Schemas Structure improvements
- W3C Schemas Datatype improvements (Charlie Bozeman) - W3C Schemas Datatype improvements (Charlie Bozeman)
- Python bindings for thread globals (St<EFBFBD>phane Bidoul), and method/class - Python bindings for thread globals (Stéphane Bidoul), and method/class
generator generator
- added --nonet option to xmllint - added --nonet option to xmllint
- documentation improvements (John Fleck) - documentation improvements (John Fleck)
@ -968,7 +968,7 @@ A bugfixes only release - Windows Makefiles (William Brack)
- First implementation of RelaxNG, added --relaxng flag to xmllint - First implementation of RelaxNG, added --relaxng flag to xmllint
- Schemas support now compiled in by default. - Schemas support now compiled in by default.
- Bug fixes: DTD validation, namespace checking, XInclude and entities, - Bug fixes: DTD validation, namespace checking, XInclude and entities,
delegateURI in XML Catalogs, HTML parser, XML reader (St<EFBFBD>phane Bidoul), delegateURI in XML Catalogs, HTML parser, XML reader (Stéphane Bidoul),
XPath parser and evaluation, UTF8ToUTF8 serialization, XML reader memory XPath parser and evaluation, UTF8ToUTF8 serialization, XML reader memory
consumption, HTML parser, HTML serialization in the presence of consumption, HTML parser, HTML serialization in the presence of
namespaces namespaces
@ -977,7 +977,7 @@ A bugfixes only release - Windows Makefiles (William Brack)
patches (Stefan Kost) patches (Stefan Kost)
- Portability fixes: NetBSD (Julio Merino), Windows (Igor Zlatkovic) - Portability fixes: NetBSD (Julio Merino), Windows (Igor Zlatkovic)
- Added python bindings for XPointer, contextual error reporting - Added python bindings for XPointer, contextual error reporting
(St<EFBFBD>phane Bidoul) (Stéphane Bidoul)
- URI/file escaping problems (Stefano Zacchiroli) - URI/file escaping problems (Stefano Zacchiroli)
@ -989,11 +989,11 @@ A bugfixes only release - Windows Makefiles (William Brack)
2.5.0: Jan 6 2003: 2.5.0: Jan 6 2003:
- New XmltextReader interface based on C# - New XmltextReader interface based on C#
API (with help of St<EFBFBD>phane Bidoul) API (with help of Stéphane Bidoul)
- Windows: more exports, including the new API (Igor) - Windows: more exports, including the new API (Igor)
- XInclude fallback fix - XInclude fallback fix
- Python: bindings for the new API, packaging (St<EFBFBD>phane Bidoul), - Python: bindings for the new API, packaging (Stéphane Bidoul),
drv_libxml2.py Python xml.sax driver (St<EFBFBD>phane Bidoul), fixes, speedup drv_libxml2.py Python xml.sax driver (Stéphane Bidoul), fixes, speedup
and iterators for Python-2.2 (Hannu Krosing) and iterators for Python-2.2 (Hannu Krosing)
- Tutorial fixes (john Fleck and Niraj Tolia) xmllint man update - Tutorial fixes (john Fleck and Niraj Tolia) xmllint man update
(John) (John)
@ -1013,7 +1013,7 @@ A bugfixes only release - Windows Makefiles (William Brack)
2.4.29: Dec 11 2002: 2.4.29: Dec 11 2002:
- Windows fixes (Igor): Windows CE port, pthread linking, python bindings - Windows fixes (Igor): Windows CE port, pthread linking, python bindings
(St<EFBFBD>phane Bidoul), Mingw (Magnus Henoch), and export list updates (Stéphane Bidoul), Mingw (Magnus Henoch), and export list updates
- Fix for prev in python bindings (ERDI Gergo) - Fix for prev in python bindings (ERDI Gergo)
- Fix for entities handling (Marcus Clarke) - Fix for entities handling (Marcus Clarke)
- Refactored the XML and HTML dumps to a single code path, fixed XHTML1 - Refactored the XML and HTML dumps to a single code path, fixed XHTML1
@ -1360,7 +1360,7 @@ it's actually not compiled in by default. The real fixes are: - a couple of bu
2.3.9: May 19 2001: 2.3.9: May 19 2001:
Lots of bugfixes, and added a basic SGML catalog support: - HTML push bugfix #54891 and another patch from Jonas Borgstr<EFBFBD>m Lots of bugfixes, and added a basic SGML catalog support: - HTML push bugfix #54891 and another patch from Jonas Borgström
- some serious speed optimization again - some serious speed optimization again
- some documentation cleanups - some documentation cleanups
- trying to get better linking on Solaris (-R) - trying to get better linking on Solaris (-R)

View File

@ -412,7 +412,7 @@ def print_function_wrapper(name, output, export, include):
# Don't delete the function entry in the caller. # Don't delete the function entry in the caller.
return 1 return 1
c_call = ""; c_call = ""
format="" format=""
format_args="" format_args=""
c_args="" c_args=""
@ -435,7 +435,7 @@ def print_function_wrapper(name, output, export, include):
c_args = c_args + " PyObject *pyobj_%s;\n" % (arg[0]) c_args = c_args + " PyObject *pyobj_%s;\n" % (arg[0])
c_convert = c_convert + \ c_convert = c_convert + \
" %s = (%s) Py%s_Get(pyobj_%s);\n" % (arg[0], " %s = (%s) Py%s_Get(pyobj_%s);\n" % (arg[0],
arg[1], t, arg[0]); arg[1], t, arg[0])
else: else:
format_args = format_args + ", &%s" % (arg[0]) format_args = format_args + ", &%s" % (arg[0])
if f == 't#': if f == 't#':
@ -443,7 +443,7 @@ def print_function_wrapper(name, output, export, include):
c_args = c_args + " int py_buffsize%d;\n" % num_bufs c_args = c_args + " int py_buffsize%d;\n" % num_bufs
num_bufs = num_bufs + 1 num_bufs = num_bufs + 1
if c_call != "": if c_call != "":
c_call = c_call + ", "; c_call = c_call + ", "
c_call = c_call + "%s" % (arg[0]) c_call = c_call + "%s" % (arg[0])
else: else:
if skipped_types.has_key(arg[1]): if skipped_types.has_key(arg[1]):
@ -468,7 +468,7 @@ def print_function_wrapper(name, output, export, include):
c_call = "\n %s->%s = %s;\n" % (args[0][0], args[1][0], c_call = "\n %s->%s = %s;\n" % (args[0][0], args[1][0],
args[1][0]) args[1][0])
else: else:
c_call = "\n %s(%s);\n" % (name, c_call); c_call = "\n %s(%s);\n" % (name, c_call)
ret_convert = " Py_INCREF(Py_None);\n return(Py_None);\n" ret_convert = " Py_INCREF(Py_None);\n return(Py_None);\n"
elif py_types.has_key(ret[0]): elif py_types.has_key(ret[0]):
(f, t, n, c) = py_types[ret[0]] (f, t, n, c) = py_types[ret[0]]
@ -476,13 +476,13 @@ def print_function_wrapper(name, output, export, include):
if file == "python_accessor" and ret[2] != None: if file == "python_accessor" and ret[2] != None:
c_call = "\n c_retval = %s->%s;\n" % (args[0][0], ret[2]) c_call = "\n c_retval = %s->%s;\n" % (args[0][0], ret[2])
else: else:
c_call = "\n c_retval = %s(%s);\n" % (name, c_call); c_call = "\n c_retval = %s(%s);\n" % (name, c_call)
ret_convert = " py_retval = libxml_%sWrap((%s) c_retval);\n" % (n,c) ret_convert = " py_retval = libxml_%sWrap((%s) c_retval);\n" % (n,c)
ret_convert = ret_convert + " return(py_retval);\n" ret_convert = ret_convert + " return(py_retval);\n"
elif py_return_types.has_key(ret[0]): elif py_return_types.has_key(ret[0]):
(f, t, n, c) = py_return_types[ret[0]] (f, t, n, c) = py_return_types[ret[0]]
c_return = " %s c_retval;\n" % (ret[0]) c_return = " %s c_retval;\n" % (ret[0])
c_call = "\n c_retval = %s(%s);\n" % (name, c_call); c_call = "\n c_retval = %s(%s);\n" % (name, c_call)
ret_convert = " py_retval = libxml_%sWrap((%s) c_retval);\n" % (n,c) ret_convert = " py_retval = libxml_%sWrap((%s) c_retval);\n" % (n,c)
ret_convert = ret_convert + " return(py_retval);\n" ret_convert = ret_convert + " return(py_retval);\n"
else: else:
@ -501,7 +501,7 @@ def print_function_wrapper(name, output, export, include):
output.write("#if %s\n" % cond) output.write("#if %s\n" % cond)
include.write("PyObject * ") include.write("PyObject * ")
include.write("libxml_%s(PyObject *self, PyObject *args);\n" % (name)); include.write("libxml_%s(PyObject *self, PyObject *args);\n" % (name))
export.write(" { (char *)\"%s\", libxml_%s, METH_VARARGS, NULL },\n" % export.write(" { (char *)\"%s\", libxml_%s, METH_VARARGS, NULL },\n" %
(name, name)) (name, name))
@ -509,16 +509,16 @@ def print_function_wrapper(name, output, export, include):
if file == "python": if file == "python":
# Those have been manually generated # Those have been manually generated
if cond != None and cond != "": if cond != None and cond != "":
include.write("#endif\n"); include.write("#endif\n")
export.write("#endif\n"); export.write("#endif\n")
output.write("#endif\n"); output.write("#endif\n")
return 1 return 1
if file == "python_accessor" and ret[0] != "void" and ret[2] is None: if file == "python_accessor" and ret[0] != "void" and ret[2] is None:
# Those have been manually generated # Those have been manually generated
if cond != None and cond != "": if cond != None and cond != "":
include.write("#endif\n"); include.write("#endif\n")
export.write("#endif\n"); export.write("#endif\n")
output.write("#endif\n"); output.write("#endif\n")
return 1 return 1
output.write("PyObject *\n") output.write("PyObject *\n")
@ -618,7 +618,7 @@ def buildStubs():
wrapper.close() wrapper.close()
print "Generated %d wrapper functions, %d failed, %d skipped\n" % (nb_wrap, print "Generated %d wrapper functions, %d failed, %d skipped\n" % (nb_wrap,
failed, skipped); failed, skipped)
print "Missing type converters: " print "Missing type converters: "
for type in unknown_types.keys(): for type in unknown_types.keys():
print "%s:%d " % (type, len(unknown_types[type])), print "%s:%d " % (type, len(unknown_types[type])),
@ -845,7 +845,7 @@ def writeDoc(name, args, indent, output):
if functions[name][0] is None or functions[name][0] == "": if functions[name][0] is None or functions[name][0] == "":
return return
val = functions[name][0] val = functions[name][0]
val = string.replace(val, "NULL", "None"); val = string.replace(val, "NULL", "None")
output.write(indent) output.write(indent)
output.write('"""') output.write('"""')
while len(val) > 60: while len(val) > 60:
@ -853,15 +853,15 @@ def writeDoc(name, args, indent, output):
val = val[1:] val = val[1:]
continue continue
str = val[0:60] str = val[0:60]
i = string.rfind(str, " "); i = string.rfind(str, " ")
if i < 0: if i < 0:
i = 60 i = 60
str = val[0:i] str = val[0:i]
val = val[i:] val = val[i:]
output.write(str) output.write(str)
output.write('\n '); output.write('\n ')
output.write(indent) output.write(indent)
output.write(val); output.write(val)
output.write(' """\n') output.write(' """\n')
def buildWrappers(): def buildWrappers():
@ -914,7 +914,7 @@ def buildWrappers():
ctypes_processed[type] = () ctypes_processed[type] = ()
for name in functions.keys(): for name in functions.keys():
found = 0; found = 0
(desc, ret, args, file, cond) = functions[name] (desc, ret, args, file, cond) = functions[name]
for type in ctypes: for type in ctypes:
classe = classes_type[type][2] classe = classes_type[type][2]
@ -969,7 +969,7 @@ def buildWrappers():
txt.write("\n# functions from module %s\n" % file) txt.write("\n# functions from module %s\n" % file)
oldfile = file oldfile = file
classes.write("def %s(" % func) classes.write("def %s(" % func)
txt.write("%s()\n" % func); txt.write("%s()\n" % func)
n = 0 n = 0
for arg in args: for arg in args:
if n != 0: if n != 0:
@ -977,7 +977,7 @@ def buildWrappers():
classes.write("%s" % arg[0]) classes.write("%s" % arg[0])
n = n + 1 n = n + 1
classes.write("):\n") classes.write("):\n")
writeDoc(name, args, ' ', classes); writeDoc(name, args, ' ', classes)
for arg in args: for arg in args:
if classes_type.has_key(arg[1]): if classes_type.has_key(arg[1]):
@ -986,26 +986,26 @@ def buildWrappers():
classes.write(" else: %s__o = %s%s\n" % classes.write(" else: %s__o = %s%s\n" %
(arg[0], arg[0], classes_type[arg[1]][0])) (arg[0], arg[0], classes_type[arg[1]][0]))
if ret[0] != "void": if ret[0] != "void":
classes.write(" ret = "); classes.write(" ret = ")
else: else:
classes.write(" "); classes.write(" ")
classes.write("libxml2mod.%s(" % name) classes.write("libxml2mod.%s(" % name)
n = 0 n = 0
for arg in args: for arg in args:
if n != 0: if n != 0:
classes.write(", "); classes.write(", ")
classes.write("%s" % arg[0]) classes.write("%s" % arg[0])
if classes_type.has_key(arg[1]): if classes_type.has_key(arg[1]):
classes.write("__o"); classes.write("__o")
n = n + 1 n = n + 1
classes.write(")\n"); classes.write(")\n")
if ret[0] != "void": if ret[0] != "void":
if classes_type.has_key(ret[0]): if classes_type.has_key(ret[0]):
# #
# Raise an exception # Raise an exception
# #
if functions_noexcept.has_key(name): if functions_noexcept.has_key(name):
classes.write(" if ret is None:return None\n"); classes.write(" if ret is None:return None\n")
elif string.find(name, "URI") >= 0: elif string.find(name, "URI") >= 0:
classes.write( classes.write(
" if ret is None:raise uriError('%s() failed')\n" " if ret is None:raise uriError('%s() failed')\n"
@ -1022,12 +1022,12 @@ def buildWrappers():
classes.write( classes.write(
" if ret is None:raise treeError('%s() failed')\n" " if ret is None:raise treeError('%s() failed')\n"
% (name)) % (name))
classes.write(" return "); classes.write(" return ")
classes.write(classes_type[ret[0]][1] % ("ret")); classes.write(classes_type[ret[0]][1] % ("ret"))
classes.write("\n"); classes.write("\n")
else: else:
classes.write(" return ret\n"); classes.write(" return ret\n")
classes.write("\n"); classes.write("\n")
txt.write("\n\n#\n# Set of classes of the module\n#\n\n") txt.write("\n\n#\n# Set of classes of the module\n#\n\n")
for classname in classes_list: for classname in classes_list:
@ -1069,14 +1069,14 @@ def buildWrappers():
for ref in list: for ref in list:
classes.write(" self.%s = None\n" % ref[1]) classes.write(" self.%s = None\n" % ref[1])
classes.write(" if _obj != None:self._o = _obj;return\n") classes.write(" if _obj != None:self._o = _obj;return\n")
classes.write(" self._o = None\n\n"); classes.write(" self._o = None\n\n")
destruct=None destruct=None
if classes_destructors.has_key(classname): if classes_destructors.has_key(classname):
classes.write(" def __del__(self):\n") classes.write(" def __del__(self):\n")
classes.write(" if self._o != None:\n") classes.write(" if self._o != None:\n")
classes.write(" libxml2mod.%s(self._o)\n" % classes.write(" libxml2mod.%s(self._o)\n" %
classes_destructors[classname]); classes_destructors[classname])
classes.write(" self._o = None\n\n"); classes.write(" self._o = None\n\n")
destruct=classes_destructors[classname] destruct=classes_destructors[classname]
flist = function_classes[classname] flist = function_classes[classname]
flist.sort(functionCompare) flist.sort(functionCompare)
@ -1088,7 +1088,7 @@ def buildWrappers():
# to avoid double free # to avoid double free
# #
if name == destruct: if name == destruct:
continue; continue
if file != oldfile: if file != oldfile:
if file == "python_accessor": if file == "python_accessor":
classes.write(" # accessors for %s\n" % (classname)) classes.write(" # accessors for %s\n" % (classname))
@ -1101,14 +1101,14 @@ def buildWrappers():
classes.write(" #\n\n") classes.write(" #\n\n")
oldfile = file oldfile = file
classes.write(" def %s(self" % func) classes.write(" def %s(self" % func)
txt.write(" %s()\n" % func); txt.write(" %s()\n" % func)
n = 0 n = 0
for arg in args: for arg in args:
if n != index: if n != index:
classes.write(", %s" % arg[0]) classes.write(", %s" % arg[0])
n = n + 1 n = n + 1
classes.write("):\n") classes.write("):\n")
writeDoc(name, args, ' ', classes); writeDoc(name, args, ' ', classes)
n = 0 n = 0
for arg in args: for arg in args:
if classes_type.has_key(arg[1]): if classes_type.has_key(arg[1]):
@ -1119,24 +1119,24 @@ def buildWrappers():
(arg[0], arg[0], classes_type[arg[1]][0])) (arg[0], arg[0], classes_type[arg[1]][0]))
n = n + 1 n = n + 1
if ret[0] != "void": if ret[0] != "void":
classes.write(" ret = "); classes.write(" ret = ")
else: else:
classes.write(" "); classes.write(" ")
classes.write("libxml2mod.%s(" % name) classes.write("libxml2mod.%s(" % name)
n = 0 n = 0
for arg in args: for arg in args:
if n != 0: if n != 0:
classes.write(", "); classes.write(", ")
if n != index: if n != index:
classes.write("%s" % arg[0]) classes.write("%s" % arg[0])
if classes_type.has_key(arg[1]): if classes_type.has_key(arg[1]):
classes.write("__o"); classes.write("__o")
else: else:
classes.write("self"); classes.write("self")
if classes_type.has_key(arg[1]): if classes_type.has_key(arg[1]):
classes.write(classes_type[arg[1]][0]) classes.write(classes_type[arg[1]][0])
n = n + 1 n = n + 1
classes.write(")\n"); classes.write(")\n")
if ret[0] != "void": if ret[0] != "void":
if classes_type.has_key(ret[0]): if classes_type.has_key(ret[0]):
# #
@ -1144,7 +1144,7 @@ def buildWrappers():
# #
if functions_noexcept.has_key(name): if functions_noexcept.has_key(name):
classes.write( classes.write(
" if ret is None:return None\n"); " if ret is None:return None\n")
elif string.find(name, "URI") >= 0: elif string.find(name, "URI") >= 0:
classes.write( classes.write(
" if ret is None:raise uriError('%s() failed')\n" " if ret is None:raise uriError('%s() failed')\n"
@ -1165,9 +1165,9 @@ def buildWrappers():
# #
# generate the returned class wrapper for the object # generate the returned class wrapper for the object
# #
classes.write(" __tmp = "); classes.write(" __tmp = ")
classes.write(classes_type[ret[0]][1] % ("ret")); classes.write(classes_type[ret[0]][1] % ("ret"))
classes.write("\n"); classes.write("\n")
# #
# Sometime one need to keep references of the source # Sometime one need to keep references of the source
@ -1184,14 +1184,14 @@ def buildWrappers():
# #
# return the class # return the class
# #
classes.write(" return __tmp\n"); classes.write(" return __tmp\n")
elif converter_type.has_key(ret[0]): elif converter_type.has_key(ret[0]):
# #
# Raise an exception # Raise an exception
# #
if functions_noexcept.has_key(name): if functions_noexcept.has_key(name):
classes.write( classes.write(
" if ret is None:return None"); " if ret is None:return None")
elif string.find(name, "URI") >= 0: elif string.find(name, "URI") >= 0:
classes.write( classes.write(
" if ret is None:raise uriError('%s() failed')\n" " if ret is None:raise uriError('%s() failed')\n"
@ -1208,12 +1208,12 @@ def buildWrappers():
classes.write( classes.write(
" if ret is None:raise treeError('%s() failed')\n" " if ret is None:raise treeError('%s() failed')\n"
% (name)) % (name))
classes.write(" return "); classes.write(" return ")
classes.write(converter_type[ret[0]] % ("ret")); classes.write(converter_type[ret[0]] % ("ret"))
classes.write("\n"); classes.write("\n")
else: else:
classes.write(" return ret\n"); classes.write(" return ret\n")
classes.write("\n"); classes.write("\n")
# #
# Generate enum constants # Generate enum constants
@ -1224,7 +1224,7 @@ def buildWrappers():
items.sort(lambda i1,i2: cmp(long(i1[1]),long(i2[1]))) items.sort(lambda i1,i2: cmp(long(i1[1]),long(i2[1])))
for name,value in items: for name,value in items:
classes.write("%s = %s\n" % (name,value)) classes.write("%s = %s\n" % (name,value))
classes.write("\n"); classes.write("\n")
txt.close() txt.close()
classes.close() classes.close()

242
python/setup.py Executable file
View File

@ -0,0 +1,242 @@
#!/usr/bin/python -u
#
# Setup script for libxml2 and libxslt if found
#
import sys, os
from distutils.core import setup, Extension
# Below ROOT, we expect to find include, include/libxml2, lib and bin.
# On *nix, it is not needed (but should not harm),
# on Windows, it is set by configure.js.
ROOT = r'/usr'
# Thread-enabled libxml2
with_threads = 1
# If this flag is set (windows only),
# a private copy of the dlls are included in the package.
# If this flag is not set, the libxml2 and libxslt
# dlls must be found somewhere in the PATH at runtime.
WITHDLLS = 1 and sys.platform.startswith('win')
def missing(file):
if os.access(file, os.R_OK) == 0:
return 1
return 0
try:
HOME = os.environ['HOME']
except:
HOME="C:"
if WITHDLLS:
# libxml dlls (expected in ROOT/bin)
dlls = [ 'iconv.dll','libxml2.dll','libxslt.dll','libexslt.dll' ]
dlls = map(lambda dll: os.path.join(ROOT,'bin',dll),dlls)
# create __init__.py for the libxmlmods package
if not os.path.exists("libxmlmods"):
os.mkdir("libxmlmods")
open("libxmlmods/__init__.py","w").close()
def altImport(s):
s = s.replace("import libxml2mod","from libxmlmods import libxml2mod")
s = s.replace("import libxsltmod","from libxmlmods import libxsltmod")
return s
if sys.platform.startswith('win'):
libraryPrefix = 'lib'
platformLibs = []
else:
libraryPrefix = ''
platformLibs = ["m","z"]
# those are examined to find
# - libxml2/libxml/tree.h
# - iconv.h
# - libxslt/xsltconfig.h
includes_dir = [
"/usr/include",
"/usr/local/include",
"/opt/include",
os.path.join(ROOT,'include'),
HOME
]
xml_includes=""
for dir in includes_dir:
if not missing(dir + "/libxml2/libxml/tree.h"):
xml_includes=dir + "/libxml2"
break
if xml_includes == "":
print "failed to find headers for libxml2: update includes_dir"
sys.exit(1)
iconv_includes=""
for dir in includes_dir:
if not missing(dir + "/iconv.h"):
iconv_includes=dir
break
if iconv_includes == "":
print "failed to find headers for libiconv: update includes_dir"
sys.exit(1)
# those are added in the linker search path for libraries
libdirs = [
os.path.join(ROOT,'lib'),
]
xml_files = ["libxml2-api.xml", "libxml2-python-api.xml",
"libxml.c", "libxml.py", "libxml_wrap.h", "types.c",
"xmlgenerator.py", "README", "TODO", "drv_libxml2.py"]
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():
if WITHDLLS:
result.write(altImport(line))
else:
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():
if WITHDLLS:
result.write(altImport(line))
else:
result.write(line)
for line in generated.readlines():
result.write(line)
head.close()
generated.close()
result.close()
with_xslt=1
else:
with_xslt=1
if with_xslt == 1:
xslt_includes=""
for dir in includes_dir:
if not missing(dir + "/libxslt/xsltconfig.h"):
xslt_includes=dir + "/libxslt"
break
if xslt_includes == "":
print "failed to find headers for libxslt: update includes_dir"
with_xslt = 0
descr = "libxml2 package"
modules = [ 'libxml2', 'drv_libxml2' ]
if WITHDLLS:
modules.append('libxmlmods.__init__')
c_files = ['libxml2-py.c', 'libxml.c', 'types.c' ]
includes= [xml_includes, iconv_includes]
libs = [libraryPrefix + "xml2"] + platformLibs
macros = []
if with_threads:
macros.append(('_REENTRANT','1'))
if with_xslt == 1:
descr = "libxml2 and libxslt package"
if not sys.platform.startswith('win'):
#
# We are gonna build 2 identical shared libs with merge initializing
# both libxml2mod and libxsltmod
#
c_files = c_files + ['libxslt-py.c', 'libxslt.c']
xslt_c_files = c_files
macros.append(('MERGED_MODULES', '1'))
else:
#
# On windows the MERGED_MODULE option is not needed
# (and does not work)
#
xslt_c_files = ['libxslt-py.c', 'libxslt.c', 'types.c']
libs.insert(0, libraryPrefix + 'exslt')
libs.insert(0, libraryPrefix + 'xslt')
includes.append(xslt_includes)
modules.append('libxslt')
extens=[Extension('libxml2mod', c_files, include_dirs=includes,
library_dirs=libdirs,
libraries=libs, define_macros=macros)]
if with_xslt == 1:
extens.append(Extension('libxsltmod', xslt_c_files, include_dirs=includes,
library_dirs=libdirs,
libraries=libs, define_macros=macros))
if missing("MANIFEST"):
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()
if WITHDLLS:
ext_package = "libxmlmods"
if sys.version >= "2.2":
base = "lib/site-packages/"
else:
base = ""
data_files = [(base+"libxmlmods",dlls)]
else:
ext_package = None
data_files = []
setup (name = "libxml2-python",
# On *nix, the version number is created from setup.py.in
# On windows, it is set by configure.js
version = "2.6.32",
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,
ext_package=ext_package,
data_files=data_files,
)
sys.exit(0)