def make(env, target, options, freeze_modules, frozen_file): # Android is built in shared mode if not isfile(join(target.builds.PYTHON, 'pyconfig.h')) or not isfile( join(target.builds.PYTHON, 'Makefile')): # __android_log is used in the interpreter itself (under PySys_WriteStdout and PySys_WriteStderr), so we need to link explicitly to it if env['STL'] == 'gnu': cmd = './configure --enable-silent-rules LDLAST="-lz" CPPFLAGS="-DBOOST_PYTHON_STATIC_LIB -DBOOST_PYTHON_SOURCE -fexceptions -frtti" CFLAGS="-DBOOST_PYTHON_STATIC_LIB -DBOOST_PYTHON_SOURCE -mandroid -fomit-frame-pointer --sysroot %s" HOSTPYTHON=%s HOSTPGEN=%s --host=arm-eabi --build=i686-pc-linux-gnu --enable-shared --prefix="%s"' % ( env['SYSROOT'], HOSTPYTHON, HOSTPGEN, target.dist, ) else: cmd = './configure --enable-silent-rules LDLAST="-lz" CFLAGS="-DBOOST_PYTHON_STATIC_LIB -DBOOST_PYTHON_SOURCE -mandroid -fomit-frame-pointer --sysroot %s" HOSTPYTHON=%s HOSTPGEN=%s --host=arm-eabi --build=i686-pc-linux-gnu --enable-shared --prefix="%s"' % ( env['SYSROOT'], HOSTPYTHON, HOSTPGEN, target.dist, ) Popen(shlex.split(cmd), cwd=target.builds.PYTHON, env=env).communicate() cmd = SED_CMD + '"s|^INSTSONAME=\(.*.so\).*|INSTSONAME=\\1|g" %s' % ( join(target.builds.PYTHON, 'Makefile')) Popen(shlex.split(cmd), cwd=target.builds.PYTHON).communicate() make_python_freeze(options.platform, freeze_modules, frozen_file) if isfile(join(target.builds.PYTHON, 'libpython2.7.so')): os.remove(join(target.builds.PYTHON, 'libpython2.7.so')) # Remove setup.py as its of no use here and it tries to compile a lot of extensions that don't work in static mode if isfile(join(target.builds.PYTHON, 'setup.py')): os.unlink(join(target.builds.PYTHON, 'setup.py')) cmd = 'make V=0 -k -j%d HOSTPYTHON=%s HOSTPGEN=%s CROSS_COMPILE=arm-eabi- CROSS_COMPILE_TARGET=yes' % ( multiprocessing.cpu_count(), HOSTPYTHON, HOSTPGEN) Popen(shlex.split(cmd), cwd=target.builds.PYTHON, env=env).communicate() # Copy some files to the skeleton directory try: if isdir(join(target.dist, 'jni', 'python', 'Include')): shutil.rmtree(join(target.dist, 'jni', 'python', 'Include')) shutil.copytree(join(target.builds.PYTHON, 'Include'), join(target.dist, 'jni', 'python', 'Include')) shutil.copy(join(target.builds.PYTHON, 'pyconfig.h'), join(target.dist, 'jni', 'python', 'pyconfig.h')) shutil.copy(join(target.builds.PYTHON, 'libpython2.7.so'), join(target.dist, 'jni', 'python', 'libpython2.7.so')) os.makedirs(join(target.dist, 'jni', 'python', 'Include', 'Modules')) shutil.copy( join(target.builds.PYTHON, 'Modules/greenlet.h'), join(target.dist, 'jni', 'python', 'Include', 'Modules', 'greenlet.h')) log('Python built successfully') except: error('Error while building Python for target') exit() return True
def make(env, target, options, freeze_modules, frozen_file): make_python_freeze('ios', freeze_modules, frozen_file) if not isfile(join(target.builds.PYTHON, 'pyconfig.h')) or not isfile( join(target.builds.PYTHON, 'Makefile')): # sdl2-config --static-libs flags are not really useful for iOS, as they are OS X oriented, so we forge them by hand if options.bare: sdlldflags = sdlcflags = '' else: sdlldflags = '-L%s/lib -lSDL2' % target.dist cmd = join(target.dist, 'bin', 'sdl2-config') + ' --cflags' sdlcflags = Popen(shlex.split(cmd), stdout=PIPE, env=env).communicate()[0].split('\n')[0] archs = '' for arch in env['ARCHS'].split(' '): archs += ' -arch ' + arch + ' ' cmd = './configure --enable-silent-rules LDLAST="-lz" LINKFORSHARED=" " DYNLOADFILE="dynload_stub.o" LDFLAGS="%s -static-libgcc %s %s" CPPFLAGS="-DBOOST_PYTHON_STATIC_LIB -DBOOST_PYTHON_SOURCE %s %s" CFLAGS="-DBOOST_PYTHON_STATIC_LIB -DBOOST_PYTHON_SOURCE %s %s %s" HOSTPYTHON=%s HOSTPGEN=%s --disable-toolbox-glue --host=arm-apple-darwin --disable-shared --prefix="%s"' % ( archs, env['LDFLAGS'], sdlldflags, archs, env['CFLAGS'], archs, env['CFLAGS'], sdlcflags, HOSTPYTHON, HOSTPGEN, target.dist, ) Popen(shlex.split(cmd), cwd=target.builds.PYTHON, env=env).communicate() cmd = SED_CMD + '"s|^INSTSONAME=\(.*.so\).*|INSTSONAME=\\1|g" %s' % ( join(target.builds.PYTHON, 'Makefile')) Popen(shlex.split(cmd), cwd=target.builds.PYTHON).communicate() # Remove the FP register saving from Greenlet as it's not needed and causes compilation problems cmd = SED_CMD + '"s|\\(^#define REGS_TO_SAVE.*\\)\\"fp\\",\\(.*\\)|\\1\\2|g" %s' % ( join(target.builds.PYTHON, 'Modules/platform/switch_arm32_gcc.h')) Popen(shlex.split(cmd), cwd=target.builds.PYTHON).communicate() # Remove setup.py as its of no use here and it tries to compile a lot of extensions that don't work in static mode if isfile(join(target.builds.PYTHON, 'setup.py')): os.unlink(join(target.builds.PYTHON, 'setup.py')) cmd = 'make V=0 install -k -j%d HOSTPYTHON=%s HOSTPGEN=%s CROSS_COMPILE=arm-apple-darwin CROSS_COMPILE_TARGET=yes' % ( multiprocessing.cpu_count(), HOSTPYTHON, HOSTPGEN) Popen(shlex.split(cmd), cwd=target.builds.PYTHON, env=env).communicate() if not isdir(join(target.dist, 'include', 'Modules')): os.makedirs(join(target.dist, 'include', 'Modules')) shutil.copy(join(target.builds.PYTHON, 'Modules/greenlet.h'), join(target.dist, 'include', 'Modules', 'greenlet.h')) # Check success if isfile(join(target.dist, 'lib', 'libpython2.7.a')): log('Python built successfully') else: error('Error building python') return True
def make(env, target, options, freeze_modules, frozen_file): if not isfile(join(target.builds.PYTHON, 'pyconfig.h')) or not isfile( join(target.builds.PYTHON, 'Makefile')): if options.bare: sdlldflags = sdlcflags = '' else: cmd = join(target.dist, 'bin', 'sdl2-config') + ' --static-libs' sdlldflags = Popen(shlex.split(cmd), stdout=PIPE).communicate( )[0].split( '\n' )[0] #.replace('-lpthread', '').replace('-ldl', '') # Removing pthread and dl to make them dynamically bound (req'd for Linux) cmd = join(target.dist, 'bin', 'sdl2-config') + ' --cflags' sdlcflags = Popen(shlex.split(cmd), stdout=PIPE).communicate()[0].split('\n')[0] # As static as possible cmd = './configure --enable-silent-rules --with-universal-archs=intel --enable-universalsdk LDLAST="-lz" LDFLAGS="-static-libgcc %s" CPPFLAGS="-DBOOST_PYTHON_STATIC_LIB -DBOOST_PYTHON_SOURCE %s" CFLAGS="-DBOOST_PYTHON_STATIC_LIB -DBOOST_PYTHON_SOURCE" LINKFORSHARED=" " DYNLOADFILE="dynload_stub.o" --disable-shared --prefix="%s"' % ( sdlldflags, sdlcflags, target.dist, ) if options.valgrind: cmd += ' --with-valgrind' Popen(shlex.split(cmd), cwd=target.builds.PYTHON).communicate() make_python_freeze('osx', freeze_modules, frozen_file) if isfile(join(target.dist, 'lib', 'libpython2.7.a')): os.remove(join(target.dist, 'lib', 'libpython2.7.a')) # Remove setup.py as its of no use here and it tries to compile a lot of extensions that don't work in static mode if isfile(join(target.builds.PYTHON, 'setup.py')): os.unlink(join(target.builds.PYTHON, 'setup.py')) cmd = 'make V=0 install -k -j%d' % multiprocessing.cpu_count() # Rebuild Python including the frozen modules! Popen(shlex.split(cmd), cwd=target.builds.PYTHON, env=env).communicate() if not isdir(join(target.dist, 'include', 'Modules')): os.makedirs(join(target.dist, 'include', 'Modules')) shutil.copy(join(target.builds.PYTHON, 'Modules/greenlet.h'), join(target.dist, 'include', 'Modules', 'greenlet.h')) # Check success if isfile(join(target.dist, 'lib', 'libpython2.7.a')): log('Python built successfully') else: error('Error building python') return True
def make(env, target, options, freeze_modules, frozen_file): make_python_freeze('ios', freeze_modules, frozen_file) if not isfile(join(target.builds.PYTHON, 'pyconfig.h')) or not isfile(join(target.builds.PYTHON, 'Makefile')): # sdl2-config --static-libs flags are not really useful for iOS, as they are OS X oriented, so we forge them by hand if options.bare: sdlldflags = sdlcflags = '' else: sdlldflags = '-L%s/lib -lSDL2' % target.dist cmd = join(target.dist, 'bin', 'sdl2-config' ) + ' --cflags' sdlcflags = Popen(shlex.split(cmd), stdout=PIPE, env=env).communicate()[0].split('\n')[0] archs = '' for arch in env['ARCHS'].split(' '): archs+= ' -arch ' + arch + ' ' cmd = './configure --enable-silent-rules LDLAST="-lz" LINKFORSHARED=" " DYNLOADFILE="dynload_stub.o" LDFLAGS="%s -static-libgcc %s %s" CPPFLAGS="-DBOOST_PYTHON_STATIC_LIB -DBOOST_PYTHON_SOURCE %s %s" CFLAGS="-DBOOST_PYTHON_STATIC_LIB -DBOOST_PYTHON_SOURCE %s %s %s" HOSTPYTHON=%s HOSTPGEN=%s --disable-toolbox-glue --host=arm-apple-darwin --disable-shared --prefix="%s"'% (archs, env['LDFLAGS'], sdlldflags, archs, env['CFLAGS'], archs, env['CFLAGS'], sdlcflags, HOSTPYTHON, HOSTPGEN, target.dist,) Popen(shlex.split(cmd), cwd = target.builds.PYTHON, env=env).communicate() cmd = SED_CMD + '"s|^INSTSONAME=\(.*.so\).*|INSTSONAME=\\1|g" %s' % (join(target.builds.PYTHON, 'Makefile')) Popen(shlex.split(cmd), cwd = target.builds.PYTHON).communicate() # Remove the FP register saving from Greenlet as it's not needed and causes compilation problems cmd = SED_CMD + '"s|\\(^#define REGS_TO_SAVE.*\\)\\"fp\\",\\(.*\\)|\\1\\2|g" %s' % (join(target.builds.PYTHON, 'Modules/platform/switch_arm32_gcc.h')) Popen(shlex.split(cmd), cwd = target.builds.PYTHON).communicate() # Remove setup.py as its of no use here and it tries to compile a lot of extensions that don't work in static mode if isfile(join(target.builds.PYTHON,'setup.py')): os.unlink(join(target.builds.PYTHON,'setup.py')) cmd = 'make V=0 install -k -j%d HOSTPYTHON=%s HOSTPGEN=%s CROSS_COMPILE=arm-apple-darwin CROSS_COMPILE_TARGET=yes' % (multiprocessing.cpu_count(), HOSTPYTHON, HOSTPGEN) Popen(shlex.split(cmd), cwd = target.builds.PYTHON, env=env).communicate() if not isdir (join(target.dist, 'include', 'Modules')): os.makedirs(join(target.dist, 'include', 'Modules')) shutil.copy(join(target.builds.PYTHON, 'Modules/greenlet.h'), join(target.dist, 'include', 'Modules', 'greenlet.h')) # Check success if isfile(join(target.dist, 'lib', 'libpython2.7.a')): log('Python built successfully') else: error('Error building python') return True
def make(env, target, options, freeze_modules, frozen_file): # Android is built in shared mode if not isfile(join(target.builds.PYTHON, 'pyconfig.h')) or not isfile(join(target.builds.PYTHON, 'Makefile')): # __android_log is used in the interpreter itself (under PySys_WriteStdout and PySys_WriteStderr), so we need to link explicitly to it if env['STL'] == 'gnu': cmd = './configure --enable-silent-rules LDLAST="-lz" CPPFLAGS="-DBOOST_PYTHON_STATIC_LIB -DBOOST_PYTHON_SOURCE -fexceptions -frtti" CFLAGS="-DBOOST_PYTHON_STATIC_LIB -DBOOST_PYTHON_SOURCE -mandroid -fomit-frame-pointer --sysroot %s" HOSTPYTHON=%s HOSTPGEN=%s --host=arm-eabi --build=i686-pc-linux-gnu --enable-shared --prefix="%s"'% (env['SYSROOT'], HOSTPYTHON, HOSTPGEN, target.dist,) else: cmd = './configure --enable-silent-rules LDLAST="-lz" CFLAGS="-DBOOST_PYTHON_STATIC_LIB -DBOOST_PYTHON_SOURCE -mandroid -fomit-frame-pointer --sysroot %s" HOSTPYTHON=%s HOSTPGEN=%s --host=arm-eabi --build=i686-pc-linux-gnu --enable-shared --prefix="%s"'% (env['SYSROOT'], HOSTPYTHON, HOSTPGEN, target.dist,) Popen(shlex.split(cmd), cwd = target.builds.PYTHON, env=env).communicate() cmd = SED_CMD + '"s|^INSTSONAME=\(.*.so\).*|INSTSONAME=\\1|g" %s' % (join(target.builds.PYTHON, 'Makefile')) Popen(shlex.split(cmd), cwd = target.builds.PYTHON).communicate() make_python_freeze(options.platform, freeze_modules, frozen_file) if isfile(join(target.builds.PYTHON, 'libpython2.7.so')): os.remove(join(target.builds.PYTHON, 'libpython2.7.so')) # Remove setup.py as its of no use here and it tries to compile a lot of extensions that don't work in static mode if isfile(join(target.builds.PYTHON,'setup.py')): os.unlink(join(target.builds.PYTHON,'setup.py')) cmd = 'make V=0 -k -j%d HOSTPYTHON=%s HOSTPGEN=%s CROSS_COMPILE=arm-eabi- CROSS_COMPILE_TARGET=yes' % (multiprocessing.cpu_count(), HOSTPYTHON, HOSTPGEN) Popen(shlex.split(cmd), cwd = target.builds.PYTHON, env=env).communicate() # Copy some files to the skeleton directory try: if isdir(join(target.dist, 'jni', 'python', 'Include')): shutil.rmtree(join(target.dist, 'jni', 'python', 'Include')) shutil.copytree(join(target.builds.PYTHON, 'Include'), join(target.dist, 'jni', 'python', 'Include')) shutil.copy(join(target.builds.PYTHON, 'pyconfig.h'), join(target.dist, 'jni', 'python', 'pyconfig.h')) shutil.copy(join(target.builds.PYTHON, 'libpython2.7.so'), join(target.dist, 'jni', 'python', 'libpython2.7.so')) os.makedirs(join(target.dist, 'jni', 'python', 'Include', 'Modules')) shutil.copy(join(target.builds.PYTHON, 'Modules/greenlet.h'), join(target.dist, 'jni', 'python', 'Include', 'Modules', 'greenlet.h')) log('Python built successfully') except: error('Error while building Python for target') exit() return True
def make(env, target, options, freeze_modules, frozen_file): if not isfile(join(target.builds.PYTHON, 'pyconfig.h')) or not isfile(join(target.builds.PYTHON, 'Makefile')): if options.bare: sdlldflags = sdlcflags = '' else: cmd = join(target.dist, 'bin', 'sdl2-config' ) + ' --static-libs' sdlldflags = Popen(shlex.split(cmd), stdout=PIPE).communicate()[0].split('\n')[0] #.replace('-lpthread', '').replace('-ldl', '') # Removing pthread and dl to make them dynamically bound (req'd for Linux) cmd = join(target.dist, 'bin', 'sdl2-config' ) + ' --cflags' sdlcflags = Popen(shlex.split(cmd), stdout=PIPE).communicate()[0].split('\n')[0] # As static as possible cmd = './configure --enable-silent-rules --with-universal-archs=intel --enable-universalsdk LDLAST="-lz" LDFLAGS="-static-libgcc %s" CPPFLAGS="-DBOOST_PYTHON_STATIC_LIB -DBOOST_PYTHON_SOURCE %s" CFLAGS="-DBOOST_PYTHON_STATIC_LIB -DBOOST_PYTHON_SOURCE" LINKFORSHARED=" " DYNLOADFILE="dynload_stub.o" --disable-shared --prefix="%s"'% (sdlldflags,sdlcflags,target.dist,) if options.valgrind: cmd += ' --with-valgrind' Popen(shlex.split(cmd), cwd = target.builds.PYTHON).communicate() make_python_freeze('osx', freeze_modules, frozen_file) if isfile(join(target.dist, 'lib', 'libpython2.7.a')): os.remove(join(target.dist, 'lib', 'libpython2.7.a')) # Remove setup.py as its of no use here and it tries to compile a lot of extensions that don't work in static mode if isfile(join(target.builds.PYTHON,'setup.py')): os.unlink(join(target.builds.PYTHON,'setup.py')) cmd = 'make V=0 install -k -j%d' % multiprocessing.cpu_count() # Rebuild Python including the frozen modules! Popen(shlex.split(cmd), cwd = target.builds.PYTHON, env=env).communicate() if not isdir (join(target.dist, 'include', 'Modules')): os.makedirs(join(target.dist, 'include', 'Modules')) shutil.copy(join(target.builds.PYTHON, 'Modules/greenlet.h'), join(target.dist, 'include', 'Modules', 'greenlet.h')) # Check success if isfile(join(target.dist, 'lib', 'libpython2.7.a')): log('Python built successfully') else: error('Error building python') return True
def make(env, target, options, freeze_modules, frozen_file): # Build LIBGC if not isfile(join(target.builds.GC, 'Makefile')): cmd = './configure LDFLAGS="%s" CPPFLAGS="%s" CFLAGS="%s" --enable-static --disable-shared --enable-cplusplus --prefix="%s"' % (env['LDFLAGS'], env['CPPFLAGS'], env['CFLAGS'], target.dist) Popen(shlex.split(cmd), cwd = target.builds.GC).communicate() if isfile(join(target.dist, 'lib', 'libgc.a')): os.remove(join(target.dist, 'lib', 'libgc.a')) if isfile(join(target.dist, 'lib', 'libgccpp.a')): os.remove(join(target.dist, 'lib', 'libgccpp.a')) cmd = 'make V=0 install -k -j%d' % multiprocessing.cpu_count() Popen(shlex.split(cmd), cwd = target.builds.GC, env=env).communicate() # Check success if isfile(join(target.dist, 'lib', 'libgc.a')) and isfile(join(target.dist, 'lib', 'libgccpp.a')): log('GC built successfully') else: error('Error building GC') exit() if not isfile(join(target.builds.PYTHON, 'pyconfig.h')) or not isfile(join(target.builds.PYTHON, 'Makefile')): # Linux is built in almost static mode (minus libdl/pthread which make OpenGL fail if compiled statically) if options.bare: sdlldflags = sdlcflags = '' else: cmd = join(target.dist, 'bin', 'sdl2-config' ) + ' --static-libs' sdlldflags = Popen(shlex.split(cmd), stdout=PIPE).communicate()[0].split('\n')[0].replace('-lpthread', '').replace('-ldl', '') # Removing pthread and dl to make them dynamically bound (req'd for Linux) cmd = join(target.dist, 'bin', 'sdl2-config' ) + ' --cflags' sdlcflags = Popen(shlex.split(cmd), stdout=PIPE).communicate()[0].split('\n')[0] + env['CFLAGS'] # http://wiki.python.org/moin/DebuggingWithGdb -> -g -fno-inline -fno-strict-aliasing if not options.forcestatic: # Mostly static, minus pthread and dl - Linux cmd = './configure --enable-silent-rules LDFLAGS="%s -L%s -Wl,--no-export-dynamic -Wl,-Bstatic" CPPFLAGS="-DBOOST_PYTHON_STATIC_LIB -DBOOST_PYTHON_SOURCE %s -static -fPIC" CFLAGS="-DBOOST_PYTHON_STATIC_LIB -DBOOST_PYTHON_SOURCE %s" LINKFORSHARED=" " LDLAST="-static-libgcc -static-libstdc++ -Wl,-Bstatic %s -lz -lgccpp -lstdc++ -lgc -Wl,-Bdynamic -lpthread -ldl" DYNLOADFILE="dynload_stub.o" --disable-shared --prefix="%s"'%\ (env['LDFLAGS'], join(target.dist, 'lib'), env['CPPFLAGS'], sdlcflags,sdlldflags,target.dist,) if options.valgrind: cmd += ' --with-valgrind' Popen(shlex.split(cmd), cwd = target.builds.PYTHON).communicate() # Patch the Makefile to optimize the static libraries inclusion... - Linux cmd = SED_CMD + '"s|^LIBS=.*|LIBS=-static-libgcc -static-libstdc++ -Wl,-Bstatic -lutil -lz -lgccpp -lstdc++ -lgc %s -Wl,-Bdynamic -lpthread -ldl |g" %s' % (env['LDFLAGS'], join(target.builds.PYTHON, 'Makefile')) Popen(shlex.split(cmd), cwd = target.builds.PYTHON).communicate() else: # Fully static config, doesnt load OpenGL from SDL under Linux for some reason cmd = './configure --enable-silent-rules LDFLAGS="%s -L%s -Wl,--no-export-dynamic -Wl,-Bstatic" CPPFLAGS="-DBOOST_PYTHON_STATIC_LIB -DBOOST_PYTHON_SOURCE %s -static -fPIC" CFLAGS="-DBOOST_PYTHON_STATIC_LIB -DBOOST_PYTHON_SOURCE %s" LINKFORSHARED=" " LDLAST="-static-libgcc -static-libstdc++ -Wl,-Bstatic %s -lz -lgccpp -lstdc++ -lgc -lpthread -ldl -lc" DYNLOADFILE="dynload_stub.o" --disable-shared --prefix="%s"'%\ (env['LDFLAGS'], join(target.dist, 'lib'), env['CPPFLAGS'], sdlcflags,sdlldflags,target.dist,) if options.valgrind: cmd += ' --with-valgrind' Popen(shlex.split(cmd), cwd = target.builds.PYTHON).communicate() # Patch the Makefile to optimize the static libraries inclusion... - Linux cmd = SED_CMD + '"s|^LIBS=.*|LIBS=-static-libgcc -static-libstdc++ -Wl,-Bstatic -lutil -lz -lgccpp -lstdc++ -lgc %s -lpthread -ldl -lc|g" %s' % (env['LDFLAGS'], join(target.builds.PYTHON, 'Makefile')) Popen(shlex.split(cmd), cwd = target.builds.PYTHON).communicate() make_python_freeze(options.platform, freeze_modules, frozen_file) if isfile(join(target.dist, 'lib', 'libpython2.7.a')): os.remove(join(target.dist, 'lib', 'libpython2.7.a')) # Remove setup.py as its of no use here and it tries to compile a lot of extensions that don't work in static mode if isfile(join(target.builds.PYTHON,'setup.py')): os.unlink(join(target.builds.PYTHON,'setup.py')) cmd = 'make V=0 install -k -j%d' % multiprocessing.cpu_count() # Rebuild Python including the frozen modules! Popen(shlex.split(cmd), cwd = target.builds.PYTHON, env=env).communicate() if not isdir (join(target.dist, 'include', 'Modules')): os.makedirs(join(target.dist, 'include', 'Modules')) shutil.copy(join(target.builds.PYTHON, 'Modules/greenlet.h'), join(target.dist, 'include', 'Modules', 'greenlet.h')) # Check success if isfile(join(target.dist, 'lib', 'libpython2.7.a')): log('Python built successfully') else: error('Error building python') return True
def make(env, target, options, freeze_modules, frozen_file): # Build LIBGC if not isfile(join(target.builds.GC, 'Makefile')): cmd = './configure LDFLAGS="%s" CPPFLAGS="%s" CFLAGS="%s" --enable-static --disable-shared --enable-cplusplus --prefix="%s"' % ( env['LDFLAGS'], env['CPPFLAGS'], env['CFLAGS'], target.dist) Popen(shlex.split(cmd), cwd=target.builds.GC).communicate() if isfile(join(target.dist, 'lib', 'libgc.a')): os.remove(join(target.dist, 'lib', 'libgc.a')) if isfile(join(target.dist, 'lib', 'libgccpp.a')): os.remove(join(target.dist, 'lib', 'libgccpp.a')) cmd = 'make V=0 install -k -j%d' % multiprocessing.cpu_count() Popen(shlex.split(cmd), cwd=target.builds.GC, env=env).communicate() # Check success if isfile(join(target.dist, 'lib', 'libgc.a')) and isfile( join(target.dist, 'lib', 'libgccpp.a')): log('GC built successfully') else: error('Error building GC') exit() if not isfile(join(target.builds.PYTHON, 'pyconfig.h')) or not isfile( join(target.builds.PYTHON, 'Makefile')): # Linux is built in almost static mode (minus libdl/pthread which make OpenGL fail if compiled statically) if options.bare: sdlldflags = sdlcflags = '' else: cmd = join(target.dist, 'bin', 'sdl2-config') + ' --static-libs' sdlldflags = Popen(shlex.split(cmd), stdout=PIPE).communicate( )[0].split('\n')[0].replace('-lpthread', '').replace( '-ldl', '' ) # Removing pthread and dl to make them dynamically bound (req'd for Linux) cmd = join(target.dist, 'bin', 'sdl2-config') + ' --cflags' sdlcflags = Popen( shlex.split(cmd), stdout=PIPE).communicate()[0].split('\n')[0] + env['CFLAGS'] # http://wiki.python.org/moin/DebuggingWithGdb -> -g -fno-inline -fno-strict-aliasing if not options.forcestatic: # Mostly static, minus pthread and dl - Linux cmd = './configure --enable-silent-rules LDFLAGS="%s -L%s -Wl,--no-export-dynamic -Wl,-Bstatic" CPPFLAGS="-DBOOST_PYTHON_STATIC_LIB -DBOOST_PYTHON_SOURCE %s -static -fPIC" CFLAGS="-DBOOST_PYTHON_STATIC_LIB -DBOOST_PYTHON_SOURCE %s" LINKFORSHARED=" " LDLAST="-static-libgcc -static-libstdc++ -Wl,-Bstatic %s -lz -lgccpp -lstdc++ -lgc -Wl,-Bdynamic -lpthread -ldl" DYNLOADFILE="dynload_stub.o" --disable-shared --prefix="%s"'%\ (env['LDFLAGS'], join(target.dist, 'lib'), env['CPPFLAGS'], sdlcflags,sdlldflags,target.dist,) if options.valgrind: cmd += ' --with-valgrind' Popen(shlex.split(cmd), cwd=target.builds.PYTHON).communicate() # Patch the Makefile to optimize the static libraries inclusion... - Linux cmd = SED_CMD + '"s|^LIBS=.*|LIBS=-static-libgcc -static-libstdc++ -Wl,-Bstatic -lutil -lz -lgccpp -lstdc++ -lgc %s -Wl,-Bdynamic -lpthread -ldl |g" %s' % ( env['LDFLAGS'], join(target.builds.PYTHON, 'Makefile')) Popen(shlex.split(cmd), cwd=target.builds.PYTHON).communicate() else: # Fully static config, doesnt load OpenGL from SDL under Linux for some reason cmd = './configure --enable-silent-rules LDFLAGS="%s -L%s -Wl,--no-export-dynamic -Wl,-Bstatic" CPPFLAGS="-DBOOST_PYTHON_STATIC_LIB -DBOOST_PYTHON_SOURCE %s -static -fPIC" CFLAGS="-DBOOST_PYTHON_STATIC_LIB -DBOOST_PYTHON_SOURCE %s" LINKFORSHARED=" " LDLAST="-static-libgcc -static-libstdc++ -Wl,-Bstatic %s -lz -lgccpp -lstdc++ -lgc -lpthread -ldl -lc" DYNLOADFILE="dynload_stub.o" --disable-shared --prefix="%s"'%\ (env['LDFLAGS'], join(target.dist, 'lib'), env['CPPFLAGS'], sdlcflags,sdlldflags,target.dist,) if options.valgrind: cmd += ' --with-valgrind' Popen(shlex.split(cmd), cwd=target.builds.PYTHON).communicate() # Patch the Makefile to optimize the static libraries inclusion... - Linux cmd = SED_CMD + '"s|^LIBS=.*|LIBS=-static-libgcc -static-libstdc++ -Wl,-Bstatic -lutil -lz -lgccpp -lstdc++ -lgc %s -lpthread -ldl -lc|g" %s' % ( env['LDFLAGS'], join(target.builds.PYTHON, 'Makefile')) Popen(shlex.split(cmd), cwd=target.builds.PYTHON).communicate() make_python_freeze(options.platform, freeze_modules, frozen_file) if isfile(join(target.dist, 'lib', 'libpython2.7.a')): os.remove(join(target.dist, 'lib', 'libpython2.7.a')) # Remove setup.py as its of no use here and it tries to compile a lot of extensions that don't work in static mode if isfile(join(target.builds.PYTHON, 'setup.py')): os.unlink(join(target.builds.PYTHON, 'setup.py')) cmd = 'make V=0 install -k -j%d' % multiprocessing.cpu_count() # Rebuild Python including the frozen modules! Popen(shlex.split(cmd), cwd=target.builds.PYTHON, env=env).communicate() if not isdir(join(target.dist, 'include', 'Modules')): os.makedirs(join(target.dist, 'include', 'Modules')) shutil.copy(join(target.builds.PYTHON, 'Modules/greenlet.h'), join(target.dist, 'include', 'Modules', 'greenlet.h')) # Check success if isfile(join(target.dist, 'lib', 'libpython2.7.a')): log('Python built successfully') else: error('Error building python') return True
def make(env, target, options, freeze_modules, frozen_file): if not isfile(join(target.builds.PYTHON, 'pyconfig.h')) or not isfile(join(target.builds.PYTHON, 'Makefile')): # Linux is built in almost static mode (minus libdl/pthread which make OpenGL fail if compiled statically) if options.bare: sdlldflags = sdlcflags = '' else: cmd = join(target.dist, 'bin', 'sdl2-config' ) + ' --static-libs' sdlldflags = Popen(shlex.split(cmd), stdout=PIPE, env=env).communicate()[0].split('\n')[0].replace('-lpthread', '').replace('-ldl', '') # Removing pthread and dl to make them dynamically bound (req'd for Linux) cmd = join(target.dist, 'bin', 'sdl2-config' ) + ' --cflags' sdlcflags = Popen(shlex.split(cmd), stdout=PIPE, env=env).communicate()[0].split('\n')[0] extralibs = "-lodbc32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lodbc32 -ladvapi32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid" cmd = 'rm -f configure' Popen(shlex.split(cmd), cwd = target.builds.PYTHON, env=env).communicate() cmd = 'autoconf' Popen(shlex.split(cmd), cwd = target.builds.PYTHON, env=env).communicate() # -DSTATIC_LIB is used for compiling libRocket as fully static under mingw cmd = './configure --enable-silent-rules ABI="longlong" LDFLAGS="%s -Wl,--no-export-dynamic -static-libgcc -static %s %s" LDLAST="-lws2_32 -lwsock32" CFLAGS="%s -DBOOST_PYTHON_STATIC_LIB -DBOOST_PYTHON_SOURCE -DSTATIC_LIB -D__MINGW32__ -DMS_WIN64 -DMS_WINDOWS -DHAVE_USABLE_WCHAR_T" CPPFLAGS="-DBOOST_PYTHON_STATIC_LIB -DBOOST_PYTHON_SOURCE -DSTATIC_LIB -static %s" LINKFORSHARED=" " LIBOBJS="import_nt.o dl_nt.o getpathp.o" THREADOBJ="Python/thread.o" DYNLOADFILE="dynload_win.o" --disable-shared HOSTPYTHON=%s HOSTPGEN=%s --host=x86_64-w64-mingw32 --build=i686-pc-linux-gnu --prefix="%s"'% (env['LDFLAGS'], sdlldflags, extralibs, env['CFLAGS'], sdlcflags, HOSTPYTHON, HOSTPGEN, target.dist,) if options.valgrind: cmd += ' --with-valgrind' Popen(shlex.split(cmd), cwd = target.builds.PYTHON, env=env).communicate() cmd = SED_CMD + '"s|\${LIBOBJDIR}fileblocks\$U\.o||g" %s' % (join(target.builds.PYTHON, 'Makefile')) Popen(shlex.split(cmd), cwd = target.builds.PYTHON).communicate() # Enable NT Threads cmd = SED_CMD + '"s|.*NT_THREADS.*|#define NT_THREADS|g" %s' % (join(target.builds.PYTHON, 'pyconfig.h')) Popen(shlex.split(cmd), cwd = target.builds.PYTHON).communicate() # Disable PTY stuff that gets activated because of errors in the configure script cmd = SED_CMD + '"s|.*HAVE_OPENPTY.*|#undef HAVE_OPENPTY|g" %s' % (join(target.builds.PYTHON, 'pyconfig.h')) Popen(shlex.split(cmd), cwd = target.builds.PYTHON).communicate() cmd = SED_CMD + '"s|.*HAVE__GETPTY.*|#undef HAVE__GETPTY|g" %s' % (join(target.builds.PYTHON, 'pyconfig.h')) Popen(shlex.split(cmd), cwd = target.builds.PYTHON).communicate() cmd = SED_CMD + '"s|.*HAVE_DEV_PTMX.*|#undef HAVE_DEV_PTMX|g" %s' % (join(target.builds.PYTHON, 'pyconfig.h')) Popen(shlex.split(cmd), cwd = target.builds.PYTHON).communicate() # Mingw64 defines pid_t as long long (8 bytes), while Python requires that sizeof(pid_t)<sizeof(long) ( and long for Windows is 4 bytes). # So, we need to override the typedef'ing done for pid_t and set it to int and a size of 4 bytes # This does not have major repercusions because the Python code for threads doesn't use this typedef at all AFAICT cmd = SED_CMD + '"s|^/\* #undef pid_t.*|#undef pid_t\\n#define pid_t int|g" %s' % (join(target.builds.PYTHON, 'pyconfig.h')) Popen(shlex.split(cmd), cwd = target.builds.PYTHON).communicate() cmd = SED_CMD + '"s|^#define SIZEOF_PID_T 8|#define SIZEOF_PID_T 4|g" %s' % (join(target.builds.PYTHON, 'pyconfig.h')) Popen(shlex.split(cmd), cwd = target.builds.PYTHON).communicate() freeze_modules += ['ntpath', 'locale'] make_python_freeze(options.platform, freeze_modules, frozen_file) if isfile(join(target.dist, 'lib', 'libpython2.7.a')): os.remove(join(target.dist, 'lib', 'libpython2.7.a')) cmd = 'make V=0 install -k -j%d HOSTPYTHON=%s HOSTPGEN=%s CROSS_COMPILE=mingw32msvc CROSS_COMPILE_TARGET=yes' % (multiprocessing.cpu_count(), HOSTPYTHON, HOSTPGEN) Popen(shlex.split(cmd), cwd = target.builds.PYTHON, env=env).communicate() if not isdir (join(target.dist, 'include', 'Modules')): os.makedirs(join(target.dist, 'include', 'Modules')) shutil.copy(join(target.builds.PYTHON, 'Modules/greenlet.h'), join(target.dist, 'include', 'Modules', 'greenlet.h')) # Check success if isfile(join(target.dist, 'lib', 'libpython2.7.a')): log('Python built successfully') else: error('Error building python') return True
def make(env, target, options, freeze_modules, frozen_file): if not isfile(join(target.builds.PYTHON, 'pyconfig.h')) or not isfile( join(target.builds.PYTHON, 'Makefile')): # Linux is built in almost static mode (minus libdl/pthread which make OpenGL fail if compiled statically) if options.bare: sdlldflags = sdlcflags = '' else: cmd = join(target.dist, 'bin', 'sdl2-config') + ' --static-libs' sdlldflags = Popen( shlex.split(cmd), stdout=PIPE, env=env ).communicate()[0].split('\n')[0].replace('-lpthread', '').replace( '-ldl', '' ) # Removing pthread and dl to make them dynamically bound (req'd for Linux) cmd = join(target.dist, 'bin', 'sdl2-config') + ' --cflags' sdlcflags = Popen(shlex.split(cmd), stdout=PIPE, env=env).communicate()[0].split('\n')[0] extralibs = "-lodbc32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lctl3d32 -lodbc32 -ladvapi32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid" cmd = 'rm -f configure' Popen(shlex.split(cmd), cwd=target.builds.PYTHON, env=env).communicate() cmd = 'autoconf' Popen(shlex.split(cmd), cwd=target.builds.PYTHON, env=env).communicate() # -DSTATIC_LIB is used for compiling libRocket as fully static under mingw cmd = './configure --enable-silent-rules LDFLAGS="-Wl,--no-export-dynamic -static-libgcc -static %s %s %s" LDLAST="-lws2_32 -lwsock32" CFLAGS="%s -DBOOST_PYTHON_STATIC_LIB -DBOOST_PYTHON_SOURCE -DSTATIC_LIB -D__MINGW32__ -DMS_WIN32 -DMS_WINDOWS -DHAVE_USABLE_WCHAR_T" CPPFLAGS="-DBOOST_PYTHON_STATIC_LIB -DBOOST_PYTHON_SOURCE -DSTATIC_LIB -static %s" LINKFORSHARED=" " LIBOBJS="import_nt.o dl_nt.o getpathp.o" THREADOBJ="Python/thread.o" DYNLOADFILE="dynload_win.o" --disable-shared HOSTPYTHON=%s HOSTPGEN=%s --host=i686-w64-mingw32 --build=i686-pc-linux-gnu --prefix="%s"' % ( env['LDFLAGS'], sdlldflags, extralibs, env['CFLAGS'], sdlcflags, HOSTPYTHON, HOSTPGEN, target.dist, ) if options.valgrind: cmd += ' --with-valgrind' Popen(shlex.split(cmd), cwd=target.builds.PYTHON, env=env).communicate() cmd = SED_CMD + '"s|\${LIBOBJDIR}fileblocks\$U\.o||g" %s' % (join( target.builds.PYTHON, 'Makefile')) Popen(shlex.split(cmd), cwd=target.builds.PYTHON).communicate() # Enable NT Threads cmd = SED_CMD + '"s|.*NT_THREADS.*|#define NT_THREADS|g" %s' % (join( target.builds.PYTHON, 'pyconfig.h')) Popen(shlex.split(cmd), cwd=target.builds.PYTHON).communicate() # Disable PTY stuff that gets activated because of errors in the configure script cmd = SED_CMD + '"s|.*HAVE_OPENPTY.*|#undef HAVE_OPENPTY|g" %s' % ( join(target.builds.PYTHON, 'pyconfig.h')) Popen(shlex.split(cmd), cwd=target.builds.PYTHON).communicate() cmd = SED_CMD + '"s|.*HAVE__GETPTY.*|#undef HAVE__GETPTY|g" %s' % ( join(target.builds.PYTHON, 'pyconfig.h')) Popen(shlex.split(cmd), cwd=target.builds.PYTHON).communicate() cmd = SED_CMD + '"s|.*HAVE_DEV_PTMX.*|#undef HAVE_DEV_PTMX|g" %s' % ( join(target.builds.PYTHON, 'pyconfig.h')) Popen(shlex.split(cmd), cwd=target.builds.PYTHON).communicate() freeze_modules += ['ntpath', 'locale'] make_python_freeze(options.platform, freeze_modules, frozen_file) if isfile(join(target.dist, 'lib', 'libpython2.7.a')): os.remove(join(target.dist, 'lib', 'libpython2.7.a')) cmd = 'make V=0 install -k -j%d HOSTPYTHON=%s HOSTPGEN=%s CROSS_COMPILE=mingw32msvc CROSS_COMPILE_TARGET=yes' % ( multiprocessing.cpu_count(), HOSTPYTHON, HOSTPGEN) Popen(shlex.split(cmd), cwd=target.builds.PYTHON, env=env).communicate() if not isdir(join(target.dist, 'include', 'Modules')): os.makedirs(join(target.dist, 'include', 'Modules')) shutil.copy(join(target.builds.PYTHON, 'Modules/greenlet.h'), join(target.dist, 'include', 'Modules', 'greenlet.h')) # Check success if isfile(join(target.dist, 'lib', 'libpython2.7.a')): log('Python built successfully') else: error('Error building python') return True
def make(env, target, options, freeze_modules, frozen_file): if not isfile(join(target.builds.PYTHON, "pyconfig.h")) or not isfile(join(target.builds.PYTHON, "Makefile")): # Linux is built in almost static mode (minus libdl/pthread which make OpenGL fail if compiled statically) if options.bare: sdlldflags = sdlcflags = "" else: cmd = join(target.dist, "bin", "sdl2-config") + " --static-libs" sdlldflags = ( Popen(shlex.split(cmd), stdout=PIPE, env=env) .communicate()[0] .split("\n")[0] .replace("-lpthread", "") .replace("-ldl", "") ) # Removing pthread and dl to make them dynamically bound (req'd for Linux) cmd = join(target.dist, "bin", "sdl2-config") + " --cflags" sdlcflags = Popen(shlex.split(cmd), stdout=PIPE, env=env).communicate()[0].split("\n")[0] extralibs = "-lodbc32 -lwinspool -lwinmm -lshell32 -lcomctl32 -lctl3d32 -lodbc32 -ladvapi32 -lopengl32 -lglu32 -lole32 -loleaut32 -luuid" cmd = "rm -f configure" Popen(shlex.split(cmd), cwd=target.builds.PYTHON, env=env).communicate() cmd = "autoconf" Popen(shlex.split(cmd), cwd=target.builds.PYTHON, env=env).communicate() # -DSTATIC_LIB is used for compiling libRocket as fully static under mingw cmd = ( './configure --enable-silent-rules LDFLAGS="-Wl,--no-export-dynamic -static-libgcc -static %s %s %s" LDLAST="-lws2_32 -lwsock32" CFLAGS="%s -DBOOST_PYTHON_STATIC_LIB -DBOOST_PYTHON_SOURCE -DSTATIC_LIB -D__MINGW32__ -DMS_WIN32 -DMS_WINDOWS -DHAVE_USABLE_WCHAR_T" CPPFLAGS="-DBOOST_PYTHON_STATIC_LIB -DBOOST_PYTHON_SOURCE -DSTATIC_LIB -static %s" LINKFORSHARED=" " LIBOBJS="import_nt.o dl_nt.o getpathp.o" THREADOBJ="Python/thread.o" DYNLOADFILE="dynload_win.o" --disable-shared HOSTPYTHON=%s HOSTPGEN=%s --host=i686-w64-mingw32 --build=i686-pc-linux-gnu --prefix="%s"' % (env["LDFLAGS"], sdlldflags, extralibs, env["CFLAGS"], sdlcflags, HOSTPYTHON, HOSTPGEN, target.dist) ) if options.valgrind: cmd += " --with-valgrind" Popen(shlex.split(cmd), cwd=target.builds.PYTHON, env=env).communicate() cmd = SED_CMD + '"s|\${LIBOBJDIR}fileblocks\$U\.o||g" %s' % (join(target.builds.PYTHON, "Makefile")) Popen(shlex.split(cmd), cwd=target.builds.PYTHON).communicate() # Enable NT Threads cmd = SED_CMD + '"s|.*NT_THREADS.*|#define NT_THREADS|g" %s' % (join(target.builds.PYTHON, "pyconfig.h")) Popen(shlex.split(cmd), cwd=target.builds.PYTHON).communicate() # Disable PTY stuff that gets activated because of errors in the configure script cmd = SED_CMD + '"s|.*HAVE_OPENPTY.*|#undef HAVE_OPENPTY|g" %s' % (join(target.builds.PYTHON, "pyconfig.h")) Popen(shlex.split(cmd), cwd=target.builds.PYTHON).communicate() cmd = SED_CMD + '"s|.*HAVE__GETPTY.*|#undef HAVE__GETPTY|g" %s' % (join(target.builds.PYTHON, "pyconfig.h")) Popen(shlex.split(cmd), cwd=target.builds.PYTHON).communicate() cmd = SED_CMD + '"s|.*HAVE_DEV_PTMX.*|#undef HAVE_DEV_PTMX|g" %s' % (join(target.builds.PYTHON, "pyconfig.h")) Popen(shlex.split(cmd), cwd=target.builds.PYTHON).communicate() freeze_modules += ["ntpath", "locale"] make_python_freeze(options.platform, freeze_modules, frozen_file) if isfile(join(target.dist, "lib", "libpython2.7.a")): os.remove(join(target.dist, "lib", "libpython2.7.a")) cmd = "make V=0 install -k -j%d HOSTPYTHON=%s HOSTPGEN=%s CROSS_COMPILE=mingw32msvc CROSS_COMPILE_TARGET=yes" % ( multiprocessing.cpu_count(), HOSTPYTHON, HOSTPGEN, ) Popen(shlex.split(cmd), cwd=target.builds.PYTHON, env=env).communicate() if not isdir(join(target.dist, "include", "Modules")): os.makedirs(join(target.dist, "include", "Modules")) shutil.copy(join(target.builds.PYTHON, "Modules/greenlet.h"), join(target.dist, "include", "Modules", "greenlet.h")) # Check success if isfile(join(target.dist, "lib", "libpython2.7.a")): log("Python built successfully") else: error("Error building python") return True