Ticket #42069: patch-setup.py.diff
File patch-setup.py.diff, 4.7 KB (added by zpeeters@…, 11 years ago) |
---|
-
setup.py
old new 1 #!/usr/bin/ python -u1 #!/usr/bin/env python -u 2 2 # 3 3 # Setup script for libxml2 and libxslt if found 4 4 # … … 56 56 # - iconv.h 57 57 # - libxslt/xsltconfig.h 58 58 includes_dir = [ 59 "/usr/include", 60 "/usr/local/include", 61 "/opt/include", 62 os.path.join(ROOT,'include'), 63 HOME 64 ]; 59 "@PREFIX@/include" 60 ] 65 61 66 62 xml_includes="" 67 63 for dir in includes_dir: 68 64 if not missing(dir + "/libxml2/libxml/tree.h"): 69 65 xml_includes=dir + "/libxml2" 70 break; 66 break 71 67 72 68 if xml_includes == "": 73 69 print("failed to find headers for libxml2: update includes_dir") … … 77 73 for dir in includes_dir: 78 74 if not missing(dir + "/iconv.h"): 79 75 iconv_includes=dir 80 break; 76 break 81 77 82 78 if iconv_includes == "": 83 79 print("failed to find headers for libiconv: update includes_dir") … … 85 81 86 82 # those are added in the linker search path for libraries 87 83 libdirs = [ 88 os.path.join(ROOT,'lib'), 84 "@PREFIX@/lib" 89 85 ] 90 86 91 87 xml_files = ["libxml2-api.xml", "libxml2-python-api.xml", 92 93 88 "libxml.c", "libxml.py", "libxml_wrap.h", "types.c", 89 "xmlgenerator.py", "README", "TODO", "drv_libxml2.py"] 94 90 95 91 xslt_files = ["libxslt-api.xml", "libxslt-python-api.xml", 96 97 92 "libxslt.c", "libxsl.py", "libxslt_wrap.h", 93 "xsltgenerator.py"] 98 94 99 95 if missing("libxml2-py.c") or missing("libxml2.py"): 100 96 try: 101 102 103 104 97 try: 98 import xmlgenerator 99 except: 100 import generator 105 101 except: 106 107 108 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) 109 105 110 106 head = open("libxml.py", "r") 111 107 generated = open("libxml2class.py", "r") … … 116 112 else: 117 113 result.write(line) 118 114 for line in generated.readlines(): 119 115 result.write(line) 120 116 head.close() 121 117 generated.close() 122 118 result.close() 123 119 124 120 with_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 xsltgenerator131 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=1149 else:150 with_xslt=1151 121 152 122 if with_xslt == 1: 153 123 xslt_includes="" 154 124 for dir in includes_dir: 155 156 157 break; 125 if not missing(dir + "/libxslt/xsltconfig.h"): 126 xslt_includes=dir + "/libxslt" 127 break 158 128 159 129 if xslt_includes == "": 160 161 130 print("failed to find headers for libxslt: update includes_dir") 131 with_xslt = 0 162 132 163 133 164 134 descr = "libxml2 package" … … 194 164 195 165 196 166 extens=[Extension('libxml2mod', c_files, include_dirs=includes, 197 198 167 library_dirs=libdirs, 168 libraries=libs, define_macros=macros)] 199 169 if with_xslt == 1: 200 170 extens.append(Extension('libxsltmod', xslt_c_files, include_dirs=includes, 201 202 171 library_dirs=libdirs, 172 libraries=libs, define_macros=macros)) 203 173 204 174 if missing("MANIFEST"): 205 206 175 manifest = open("MANIFEST", "w") 207 176 manifest.write("setup.py\n") 208 177 for file in xml_files: 209 178 manifest.write(file + "\n") 210 179 if with_xslt == 1: 211 212 180 for file in xslt_files: 181 manifest.write(file + "\n") 213 182 manifest.close() 214 183 215 184 if WITHDLLS: