Ticket #42069: patch-setup.py.diff

File patch-setup.py.diff, 4.7 KB (added by zpeeters@…, 10 years ago)

This file replaces the current patch-setup.py.diff and includes those changes.

  • setup.py

    old new  
    1 #!/usr/bin/python -u
     1#!/usr/bin/env python -u
    22#
    33# Setup script for libxml2 and libxslt if found
    44#
     
    5656# - iconv.h
    5757# - libxslt/xsltconfig.h
    5858includes_dir = [
    59 "/usr/include",
    60 "/usr/local/include",
    61 "/opt/include",
    62 os.path.join(ROOT,'include'),
    63 HOME
    64 ];
     59"@PREFIX@/include"
     60]
    6561
    6662xml_includes=""
    6763for dir in includes_dir:
    6864    if not missing(dir + "/libxml2/libxml/tree.h"):
    6965        xml_includes=dir + "/libxml2"
    70         break;
     66    break
    7167
    7268if xml_includes == "":
    7369    print("failed to find headers for libxml2: update includes_dir")
     
    7773for dir in includes_dir:
    7874    if not missing(dir + "/iconv.h"):
    7975        iconv_includes=dir
    80         break;
     76    break
    8177
    8278if iconv_includes == "":
    8379    print("failed to find headers for libiconv: update includes_dir")
     
    8581
    8682# those are added in the linker search path for libraries
    8783libdirs = [
    88 os.path.join(ROOT,'lib'),
     84"@PREFIX@/lib"
    8985]
    9086
    9187xml_files = ["libxml2-api.xml", "libxml2-python-api.xml",
    92              "libxml.c", "libxml.py", "libxml_wrap.h", "types.c",
    93              "xmlgenerator.py", "README", "TODO", "drv_libxml2.py"]
     88            "libxml.c", "libxml.py", "libxml_wrap.h", "types.c",
     89            "xmlgenerator.py", "README", "TODO", "drv_libxml2.py"]
    9490
    9591xslt_files = ["libxslt-api.xml", "libxslt-python-api.xml",
    96              "libxslt.c", "libxsl.py", "libxslt_wrap.h",
    97              "xsltgenerator.py"]
     92            "libxslt.c", "libxsl.py", "libxslt_wrap.h",
     93            "xsltgenerator.py"]
    9894
    9995if missing("libxml2-py.c") or missing("libxml2.py"):
    10096    try:
    101         try:
    102             import xmlgenerator
    103         except:
    104             import generator
     97        try:
     98            import xmlgenerator
     99        except:
     100            import generator
    105101    except:
    106         print("failed to find and generate stubs for libxml2, aborting ...")
    107         print(sys.exc_info()[0], sys.exc_info()[1])
    108         sys.exit(1)
     102        print("failed to find and generate stubs for libxml2, aborting ...")
     103        print(sys.exc_info()[0], sys.exc_info()[1])
     104        sys.exit(1)
    109105
    110106    head = open("libxml.py", "r")
    111107    generated = open("libxml2class.py", "r")
     
    116112        else:
    117113            result.write(line)
    118114    for line in generated.readlines():
    119         result.write(line)
     115        result.write(line)
    120116    head.close()
    121117    generated.close()
    122118    result.close()
    123119
    124120with_xslt=0
    125 if missing("libxslt-py.c") or missing("libxslt.py"):
    126     if missing("xsltgenerator.py") or missing("libxslt-api.xml"):
    127         print("libxslt stub generator not found, libxslt not built")
    128     else:
    129         try:
    130             import xsltgenerator
    131         except:
    132             print("failed to generate stubs for libxslt, aborting ...")
    133             print(sys.exc_info()[0], sys.exc_info()[1])
    134         else:
    135             head = open("libxsl.py", "r")
    136             generated = open("libxsltclass.py", "r")
    137             result = open("libxslt.py", "w")
    138             for line in head.readlines():
    139                 if WITHDLLS:
    140                     result.write(altImport(line))
    141                 else:
    142                     result.write(line)
    143             for line in generated.readlines():
    144                 result.write(line)
    145             head.close()
    146             generated.close()
    147             result.close()
    148             with_xslt=1
    149 else:
    150     with_xslt=1
    151121
    152122if with_xslt == 1:
    153123    xslt_includes=""
    154124    for dir in includes_dir:
    155         if not missing(dir + "/libxslt/xsltconfig.h"):
    156             xslt_includes=dir + "/libxslt"
    157             break;
     125        if not missing(dir + "/libxslt/xsltconfig.h"):
     126            xslt_includes=dir + "/libxslt"
     127            break
    158128
    159129    if xslt_includes == "":
    160         print("failed to find headers for libxslt: update includes_dir")
    161         with_xslt = 0
     130        print("failed to find headers for libxslt: update includes_dir")
     131        with_xslt = 0
    162132
    163133
    164134descr = "libxml2 package"
     
    194164
    195165
    196166extens=[Extension('libxml2mod', c_files, include_dirs=includes,
    197                   library_dirs=libdirs,
    198                   libraries=libs, define_macros=macros)]
     167                library_dirs=libdirs,
     168                libraries=libs, define_macros=macros)]
    199169if with_xslt == 1:
    200170    extens.append(Extension('libxsltmod', xslt_c_files, include_dirs=includes,
    201                             library_dirs=libdirs,
    202                             libraries=libs, define_macros=macros))
     171                library_dirs=libdirs,
     172                libraries=libs, define_macros=macros))
    203173
    204174if missing("MANIFEST"):
    205 
    206175    manifest = open("MANIFEST", "w")
    207176    manifest.write("setup.py\n")
    208177    for file in xml_files:
    209178        manifest.write(file + "\n")
    210179    if with_xslt == 1:
    211         for file in xslt_files:
    212             manifest.write(file + "\n")
     180        for file in xslt_files:
     181            manifest.write(file + "\n")
    213182    manifest.close()
    214183
    215184if WITHDLLS: