diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ae69302..235cdf49 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -521,9 +521,6 @@ if(LIBXML2_WITH_PYTHON) COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/python/generator.py - ${CMAKE_CURRENT_SOURCE_DIR}/doc/libxml2-api.xml - ${CMAKE_CURRENT_SOURCE_DIR}/python/libxml2-python-api.xml - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} ) file(READ python/libxml.py LIBXML_PY) diff --git a/python/Makefile.am b/python/Makefile.am index c9f3efad..76018a9e 100644 --- a/python/Makefile.am +++ b/python/Makefile.am @@ -38,7 +38,7 @@ CLEANFILES = libxml2.py $(GENERATED) all-local: libxml2.py $(GENERATED): $(srcdir)/generator.py $(API_DESC) - $(PYTHON) $(srcdir)/generator.py $(srcdir) + $(PYTHON) $(srcdir)/generator.py $(builddir) # libxml.c #includes libxml2-export.c libxml.$(OBJEXT): libxml2-export.c diff --git a/python/generator.py b/python/generator.py index 9efdbab4..6b3edca7 100755 --- a/python/generator.py +++ b/python/generator.py @@ -13,9 +13,14 @@ import string if __name__ == "__main__": # launched as a script srcPref = os.path.dirname(sys.argv[0]) + try: + dstPref = sys.argv[1] + except IndexError: + dstPref = os.getcwd() else: # imported srcPref = os.path.dirname(__file__) + dstPref = os.getcwd() ####################################################################### # @@ -701,11 +706,11 @@ def buildStubs(): failed = 0 skipped = 0 - include = open("libxml2-py.h", "w") + include = open(os.path.join(dstPref, "libxml2-py.h"), "w") include.write("/* Generated */\n\n") - export = open("libxml2-export.c", "w") + export = open(os.path.join(dstPref, "libxml2-export.c"), "w") export.write("/* Generated */\n\n") - wrapper = open("libxml2-py.c", "w") + wrapper = open(os.path.join(dstPref, "libxml2-py.c"), "w") wrapper.write("/* Generated */\n\n") wrapper.write("#define PY_SSIZE_T_CLEAN\n") wrapper.write("#include \n") @@ -1087,8 +1092,8 @@ def buildWrappers(): info = (0, func, name, ret, args, file) function_classes['None'].append(info) - classes = open("libxml2class.py", "w") - txt = open("libxml2class.txt", "w") + classes = open(os.path.join(dstPref, "libxml2class.py"), "w") + txt = open(os.path.join(dstPref, "libxml2class.txt"), "w") txt.write(" Generated Classes for libxml2-python\n\n") txt.write("#\n# Global functions of the module\n#\n\n")