def main(args): # various cherry picks from HEAD that fix regression in the latest release apply_patches('libxml2' + os.sep) if iswindows: run(*('cscript.exe configure.js include={0}/include' ' lib={0}/lib prefix={0} zlib=yes iconv=yes'.format( PREFIX.replace(os.sep, '/')).split()), cwd='win32') replace_in_file('win32/Makefile.msvc', 'iconv.lib', 'libiconv.lib') run(f'"{NMAKE}" /f Makefile.msvc', cwd='win32') install_tree('include/libxml', 'include/libxml2') for f in walk('.'): if f.endswith('.dll'): install_binaries(f, 'bin') elif f.endswith('.lib'): install_binaries(f) else: # https://gitlab.gnome.org/GNOME/libxml2/-/issues/204 replace_in_file('encoding.c', re.compile(r'\bTRUE\b'), '1') # ICU is needed to use libxml2 in qt-webengine simple_build( '--disable-dependency-tracking --disable-static --enable-shared' ' --without-python --without-debug --with-iconv={0}' ' --with-zlib={0} --with-icu'.format(PREFIX)) for path in walk(build_dir()): if path.endswith('/xml2-config'): replace_in_file(path, re.compile(b'(?m)^prefix=.+'), f'prefix={PREFIX}')
def main(args): if iswindows: run(*('cscript.exe configure.js include={0}/include' ' include={0}/include/libxml2 lib={0}/lib prefix={0}' ' zlib=yes iconv=no'.format(PREFIX.replace(os.sep, '/')).split()), cwd='win32') for f in walk('.'): bname = os.path.basename(f) if bname.startswith('Makefile'): replace_in_file(f, '/OPT:NOWIN98', '', missing_ok=True) elif bname == 'xsltconfig.h': replace_in_file(f, '@WITH_PROFILER@', '1') run(f'"{NMAKE}" /f Makefile.msvc', cwd='win32') install_tree('libxslt', 'include') install_tree('libexslt', 'include') for f in walk('.'): if f.endswith('.dll'): install_binaries(f, 'bin') elif f.endswith('.lib'): install_binaries(f) else: env = {} if ismacos: env['PATH'] = BIN + os.pathsep + os.environ['PATH'] with ModifiedEnv(**env): simple_build('--disable-dependency-tracking --disable-static' ' --enable-shared --without-python --without-debug')
def windows_python(args): with open('PCbuild/msbuild.rsp', 'w') as f: print(f'/p:PlatformToolset={get_platform_toolset()}', file=f) print(f'/p:WindowsTargetPlatformVersion={get_windows_sdk()}', file=f) # dont need python 3 to get externals, use git instead replace_in_file('PCbuild\\get_externals.bat', re.compile(br'^call.+find_python.bat.+$', re.MULTILINE), '') env = {} if is64bit: env['PROCESSOR_ARCHITECTURE'] = env['PROCESSOR_ARCHITEW6432'] = 'AMD64' try: run( 'PCbuild\\build.bat', '-e', '--no-tkinter', '-c', 'Release', '-m', '-p', ('x64' if is64bit else 'Win32'), '-v', '-t', 'Build', '--pgo', env=env ) # Run the tests # run('PCbuild\\amd64\\python.exe', 'Lib/test/regrtest.py', '-u', # 'network,cpu,subprocess,urlfetch') # Do not read mimetypes from the registry replace_in_file( 'Lib\\mimetypes.py', re.compile(br'try:.*?import\s+winreg.*?None', re.DOTALL), r'_winreg = None') bindir = 'PCbuild\\amd64' if is64bit else 'PCbuild\\win32' install_binaries(bindir + os.sep + '*.exe', 'private\\python') install_binaries(bindir + os.sep + 'python*.dll', 'private\\python') install_binaries(bindir + os.sep + '*.pyd', 'private\\python\\DLLs') install_binaries(bindir + os.sep + '*.dll', 'private\\python\\DLLs') for x in glob.glob( os.path.join(build_dir(), 'private\\python\\DLLs\\python*.dll')): os.remove(x) install_binaries(bindir + os.sep + '*.lib', 'private\\python\\libs') copy_headers('PC\\pyconfig.h', 'private\\python\\include') copy_headers('Include\\*.h', 'private\\python\\include') copy_headers('Include\\cpython', 'private\\python\\include') with open('Lib/sitecustomize.py', 'w') as f: f.write(''' import os for path in ('{p}/bin', '{p}/qt/bin'): if os.path.exists(path): os.add_dll_directory(path) '''.format(p=PREFIX.replace('\\', '/'))) shutil.copytree('Lib', os.path.join(build_dir(), 'private\\python\\Lib')) finally: # bloody git creates files with no write permission import stat for path in walk('externals'): os.chmod(path, stat.S_IWRITE) os.remove(path)
def main(args): env = {} p = PREFIX.replace(os.sep, '/') env = dict( UNRAR_INCLUDE='{}/include'.format(p), UNRAR_LIBDIRS='{0}/lib'.format(p), ) with ModifiedEnv(**env): python_build() python_install()
def main(args): env = {} p = PREFIX.replace(os.sep, '/') env = dict( LIBXML_INCLUDE_DIRS='{0}/include{1}{0}/include/libxml2'.format(p, os.pathsep), LIBXML_LIB_DIRS='{0}/lib'.format(p), LIBXML_LIBS='libxml2' if iswindows else 'xml2', ) with ModifiedEnv(**env): python_build() python_install()
def main(args): env = {} p = PREFIX.replace(os.sep, '/') env = dict( UNRAR_INCLUDE='{}/include'.format(p), UNRAR_LIBDIRS='{0}/lib'.format(p), ) if iswindows: replace_in_file('src/unrardll/wrapper.cpp', ' ssize_t written', ' Py_ssize_t written') with ModifiedEnv(**env): python_build() python_install()
def main(args): p = PREFIX.replace('\\', '/') shutil.copy(os.path.join(PREFIX, 'src', 'chm_lib.c'), 'chm') shutil.copy(os.path.join(PREFIX, 'src', 'lzx.c'), 'chm') shutil.copy(os.path.join(PREFIX, 'src', 'lzx.h'), 'chm') shutil.copy(os.path.join(PREFIX, 'include', 'chm_lib.h'), 'chm') replace_in_file('setup.py', 'search.c"', 'search.c", "chm/chm_lib.c", "chm/lzx.c"') replace_in_file( 'setup.py', 'libraries=["chm"]', f'include_dirs=["{p}/include"],' 'define_macros=[("strcasecmp", "_stricmp"),' '("strncasecmp", "_strnicmp"), ("WIN32", "1")],') python_build() python_install()
def main(args): if iswindows: # libxml2 does not depend on iconv in our windows build replace_in_file('setupinfo.py', ", 'iconv'", '') run( PYTHON, *('setup.py build_ext -I {0}/include;{0}/include/libxml2 -L {0}/lib' .format(PREFIX.replace(os.sep, '/')).split())) else: run(PYTHON, *('setup.py build_ext -I {0}/include/libxml2 -L {0}/lib'.format( PREFIX).split()), library_path=True) python_build() python_install()
def main(args): if iswindows: # cmake cannot find openssl replace_in_file('CMakeLists.txt', 'FIND_PACKAGE(LIBCRYPTO)', ('SET(LIBCRYPTO_FOUND "1")\n' 'SET(LIBCRYPTO_INCLUDE_DIR "{0}/include")\n' 'SET(LIBCRYPTO_LIBRARIES "{0}/lib/libcrypto.lib")\n' 'SET(PODOFO_HAVE_OPENSSL_1_1 "1")\n').format( PREFIX.replace(os.sep, '/'))) windows_cmake_build(WANT_LIB64='FALSE', PODOFO_BUILD_SHARED='TRUE', PODOFO_BUILD_STATIC='False', FREETYPE_INCLUDE_DIR=f"{PREFIX}/include/freetype2", nmake_target='podofo_shared') copy_headers('build/podofo_config.h', 'include/podofo') copy_headers('src/podofo/*', 'include/podofo') for f in walk(): if f.endswith('.dll'): install_binaries(f, 'bin') elif f.endswith('.lib'): install_binaries(f, 'lib') else: if ismacos: replace_in_file( 'CMakeLists.txt', 'FIND_PACKAGE(FREETYPE REQUIRED)', ('SET(FREETYPE_FOUND "1")\n' 'SET(FREETYPE_INCLUDE_DIR "{0}/include/freetype2")\n' 'SET(FREETYPE_LIBRARIES "{0}/lib/libfreetype.dylib")' ).format(PREFIX)) replace_in_file('src/podofo/base/PdfDate.cpp', 'struct tm _tm{}', 'struct tm _tm = {0}') cmake_build( make_args='podofo_shared', PODOFO_BUILD_LIB_ONLY='TRUE', PODOFO_BUILD_SHARED='TRUE', PODOFO_BUILD_STATIC='FALSE', )
def main(args): if iswindows: run(*('cscript.exe configure.js include={0}/include' ' lib={0}/lib prefix={0} zlib=yes iconv=no'.format( PREFIX.replace(os.sep, '/')).split()), cwd='win32') run(f'"{NMAKE}" /f Makefile.msvc', cwd='win32') install_tree('include/libxml', 'include/libxml2') for f in walk('.'): if f.endswith('.dll'): install_binaries(f, 'bin') elif f.endswith('.lib'): install_binaries(f) else: # ICU is needed to use libxml2 in qt-webengine simple_build( '--disable-dependency-tracking --disable-static --enable-shared' ' --without-python --without-debug --with-iconv={0}' ' --with-zlib={0} --with-icu'.format(PREFIX)) for path in walk(build_dir()): if path.endswith('/xml2-config'): replace_in_file(path, re.compile(b'(?m)^prefix=.+'), f'prefix={PREFIX}')