def _patch__init__(self): init = join(self.ctx.dist_dir, 'root', 'python3', 'lib', 'python3.7', 'site-packages', 'zbarlight', "__init__.py") shprint( sh.sed, "-i.bak", "s/__version__ = pkg_resources.get_distribution('zbarlight').version'" "/__version__ = '{version}'/g", init)
def install(self): arch = list(self.filtered_archs)[0] build_env = self.get_build_env() build_subdir = self.get_build_subdir(arch.arch) build_env["PATH"] = os.environ["PATH"] shprint(sh.make, self.ctx.concurrent_make, "-C", build_subdir, "install", _env=build_env) shutil.copy(join(self.ctx.dist_dir, "hostpython3", "bin", "python3"), join(self.ctx.dist_dir, "hostpython3", "bin", "python")) """ I don't like this kind of "patches". sysconfig was overriding our cflags and extensions were failing to build. This hack resets the cflags provided by sysconfig. """ with open( join(self.ctx.dist_dir, "hostpython3", "lib", "python3.8", "distutils", "sysconfig.py"), 'r') as sysconfigfile: lines = sysconfigfile.readlines() lines[192] = ' cflags = ""\n' with open( join(self.ctx.dist_dir, "hostpython3", "lib", "python3.8", "distutils", "sysconfig.py"), 'w') as sysconfigfile: sysconfigfile.writelines(lines)
def build_arch(self, arch): build_env = self.get_zbar_env(arch) hostpython = sh.Command(self.ctx.hostpython) shprint(hostpython, "setup.py", "build", _env=build_env) self.apply_patch("zbarlight_1_2.patch" ) #Issue getting the version, hard coding for now self.biglink()
def install(self): """ Do the equivalent of python setup.py build_ext install while setting the proper environment variables """ arch = list(self.filtered_archs)[0] build_env = self.get_recipe_env(arch) hostpython = sh.Command(self.ctx.hostpython) subdir_path = self.get_build_dir(arch.arch) setup_path = join(subdir_path,"setup.py") dest_dir = join (self.ctx.dist_dir, "root", "python") build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python2.7', 'site-packages') #Note: Throws error if PATH is not set. I am not sure if this will cause problems # in other architectures. build_env['PATH']= os.environ.get('PATH') shprint(hostpython, setup_path, "build_ext", #"--compiler=mingw32", #note: throws clang error "install", _env=build_env)
def build_arch(self, arch): shprint( sh.xcodebuild, "ONLY_ACTIVE_ARCH=NO", "ARCHS={}".format(arch.arch), "HEADER_SEARCH_PATHS={}".format( join(self.ctx.include_dir, "common", "SDL2")), "-sdk", arch.sdk, "-project", "Xcode-iOS/SDL_image.xcodeproj", "-target", "libSDL_image", "-configuration", "Release")
def install(self): arch = list(self.filtered_archs)[0] build_dir = self.get_build_dir(arch.arch) os.chdir(build_dir) hostpython = sh.Command(self.ctx.hostpython) #shprint(hostpython, "bootstrap.py") #shprint(hostpython, "setup.py", "install", "--prefix=" + join(self.ctx.dist_dir, "hostpython")) sh.curl("-O", "https://bootstrap.pypa.io/ez_setup.py") shprint(hostpython, "./ez_setup.py") # Extract setuptools egg and remove .pth files. Otherwise subsequent # python package installations using setuptools will raise exceptions. # Setuptools version 28.3.0 site_packages_path = join(self.ctx.dist_dir, 'hostpython', 'lib', 'python2.7', 'site-packages') os.chdir(site_packages_path) with open('setuptools.pth', 'r') as f: setuptools_egg_path = f.read().strip('./').strip('\n') unzip = sh.Command('unzip') shprint(unzip, setuptools_egg_path) os.remove(setuptools_egg_path) os.remove('setuptools.pth') os.remove('easy-install.pth') shutil.rmtree('EGG-INFO')
def biglink(self): dirs = [] for root, dirnames, filenames in os.walk(self.build_dir): if fnmatch.filter(filenames, "*.so.libs"): dirs.append(root) cmd = sh.Command(join(self.ctx.root_dir, "tools", "biglink")) shprint(cmd, join(self.build_dir, "libpil.a"), *dirs)
def postbuild_arch(self, arch): # include _sqlite module to .a py_arch = arch.arch if py_arch == "armv7": py_arch = "arm" elif py_arch == "arm64": py_arch = "aarch64" tmp_folder = "temp.ios-{}-3.7{}".format(py_arch, self.build_dir) build_env = self.get_build_env(arch) for o_file in [ "cache.o", "cursor.o", "module.o", "row.o", "util.o", "connection.o", "microprotocols.o", "prepare_protocol.o", "statement.o", ]: shprint(sh.Command(build_env['AR']), "-r", "{}/{}".format(self.build_dir, self.library), "{}/build/{}/Modules/_sqlite/{}".format(self.build_dir, tmp_folder, o_file)) print("Added _sqlite to archive")
def install(self): arch = list(self.filtered_archs)[0] build_dir = self.get_build_dir(arch.arch) os.chdir(build_dir) hostpython = sh.Command(self.ctx.hostpython) build_env = arch.get_env() dest_dir = join(self.ctx.dist_dir, "root", "python") build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python2.7', 'site-packages') cmd = sh.Command("sed") shprint(cmd, "-i", "", "s/,.*Feature//g", "./setup.py", _env=build_env) shprint(cmd, "-i", "", "s/setuptools/distutils.core/g", "./setup.py", _env=build_env) shprint(cmd, "-i", "", "/^speedups = Feature/,/^)$/s/.*//g", "./setup.py", _env=build_env) shprint(cmd, "-i", "", "s/features\['speedups'\].*=.*speedups/pass/g", "./setup.py", _env=build_env) shprint(hostpython, "setup.py", "install", "--prefix", dest_dir, _env=build_env)
def build_i386(self): sdk_path = sh.xcrun("--sdk", "macosx", "--show-sdk-path").strip() build_env = self.ctx.env.copy() build_env["CC"] = "clang -Qunused-arguments -fcolor-diagnostics" build_env["LDFLAGS"] = " ".join([ "-lsqlite3", "-lffi", "-L{}".format(join(self.ctx.dist_dir, "lib")) ]) build_env["CFLAGS"] = " ".join([ "--sysroot={}".format(sdk_path), "-I{}".format(join(self.ctx.dist_dir, "include", "i386", "libffi")) ]) configure = sh.Command(join(self.build_dir, "configure")) shprint(configure, "--prefix={}".format(join(self.ctx.dist_dir, "hostpython")), "--disable-toolbox-glue", "--without-gcc", _env=build_env) shprint(sh.make, "-C", self.build_dir, "-j4", "python.exe", "Parser/pgen", _env=build_env) shutil.move("python.exe", "hostpython") shutil.move("Parser/pgen", "Parser/hostpgen")
def build_arch(self, arch): build_env = arch.get_env() configure = sh.Command(join(self.build_dir, "configure")) shprint(configure, "CC={}".format(build_env["CC"]), "LD={}".format(build_env["LD"]), "CFLAGS={}".format(build_env["CFLAGS"]), "LDFLAGS={} -undefined dynamic_lookup".format(build_env["LDFLAGS"]), "--without-pymalloc", "--disable-toolbox-glue", "--host={}-apple-darwin".format(arch), "--prefix=/python", "--with-system-ffi", "--without-doc-strings", "--enable-ipv6", _env=build_env) self._patch_pyconfig() self.apply_patch("ctypes_duplicate.patch") self.apply_patch("ctypes_duplicate_longdouble.patch") shprint(sh.make, self.ctx.concurrent_make, "CROSS_COMPILE_TARGET=yes", "HOSTPYTHON={}".format(self.ctx.hostpython), "HOSTPGEN={}".format(self.ctx.hostpgen))
def build_arch(self, arch): build_env = arch.get_env() configure = sh.Command(join(self.build_dir, "configure")) shprint(configure, "CC={}".format(build_env["CC"]), "LD={}".format(build_env["LD"]), "CFLAGS={}".format(build_env["CFLAGS"]), "LDFLAGS={} -undefined dynamic_lookup".format( build_env["LDFLAGS"]), "--without-pymalloc", "--disable-toolbox-glue", "--host={}-apple-darwin".format(arch), "--prefix=/python", "--with-system-ffi", "--without-doc-strings", "--enable-ipv6", _env=build_env) self._patch_pyconfig() self.apply_patch("ctypes_duplicate.patch") self.apply_patch("ctypes_duplicate_longdouble.patch") shprint(sh.make, self.ctx.concurrent_make, "CROSS_COMPILE_TARGET=yes", "HOSTPYTHON={}".format(self.ctx.hostpython), "HOSTPGEN={}".format(self.ctx.hostpgen))
def install(self): """ Do the equivalent of python setup.py build_ext install while setting the proper environment variables """ arch = list(self.filtered_archs)[0] build_env = self.get_recipe_env(arch) hostpython = sh.Command(self.ctx.hostpython) subdir_path = self.get_build_dir(arch.arch) setup_path = join(subdir_path, "setup.py") dest_dir = join(self.ctx.dist_dir, "root", "python") build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python2.7', 'site-packages') #Note: Throws error if PATH is not set. I am not sure if this will cause problems # in other architectures. build_env['PATH'] = os.environ.get('PATH') shprint( hostpython, setup_path, "build_ext", #"--compiler=mingw32", #note: throws clang error "install", _env=build_env)
def install(self): arch = list(self.filtered_archs)[0] build_env = arch.get_env() build_dir = self.get_build_dir(arch.arch) build_env["PATH"] = os.environ["PATH"] # Compiling sometimes looks for Python-ast.py in the 'Python' i.s.o. # the 'hostpython' folder. Create a symlink to fix. See issue #201 shprint(sh.ln, "-s", join(build_dir, "hostpython"), join(build_dir, "Python")) shprint(sh.make, self.ctx.concurrent_make, "-C", build_dir, "bininstall", "inclinstall", _env=build_env) pylib_dir = join(self.ctx.dist_dir, "hostpython", "lib", "python2.7") if exists(pylib_dir): shutil.rmtree(pylib_dir) shutil.copytree( join(build_dir, "Lib"), pylib_dir) ensure_dir(join(pylib_dir, "config")) shutil.copy( join(build_dir, "Makefile"), join(pylib_dir, "config", "Makefile")) shutil.copy( join(build_dir, "Parser", "pgen"), join(self.ctx.dist_dir, "hostpython", "bin", "pgen"))
def cythonize_build(self): # don't use the cythonize, pyobjus don't support method rewriting shprint(sh.find, self.build_dir, "-iname", "*.pyx", "-exec", "cython", "{}", ";") # ffi is installed somewhere else, this include doesn't work # XXX ideally, we need to fix libffi installation... shprint(sh.sed, "-i.bak", "s/ffi\///g", "pyobjus/pyobjus.c")
def build_arch(self, arch): env = arch.get_env() shprint(sh.xcodebuild, self.ctx.concurrent_xcodebuild, "ONLY_ACTIVE_ARCH=NO", "ARCHS={}".format(arch.arch), "CC={}".format(env['CC']), "-sdk", arch.sdk, "-project", "Xcode-iOS/SDL/SDL.xcodeproj", "-target", "libSDL-iOS", "-configuration", "Release")
def build_arch(self, arch): shprint( sh.xcodebuild, "ONLY_ACTIVE_ARCH=NO", "ARCHS={}".format(arch.arch), "HEADER_SEARCH_PATHS=$HEADER_SEARCH_PATHS {}".format(" ".join( arch.include_dirs)), "-sdk", arch.sdk, "-project", "Xcode-iOS/SDL_mixer.xcodeproj", "-target", "Static Library", "-configuration", "Release")
def install(self): arch = list(self.filtered_archs)[0] build_env = arch.get_env() build_dir = self.get_build_dir(arch.arch) build_env["PATH"] = os.environ["PATH"] # Compiling sometimes looks for Python-ast.py in the 'Python' i.s.o. # the 'hostpython' folder. Create a symlink to fix. See issue #201 shprint(sh.ln, "-s", join(build_dir, "hostpython2"), join(build_dir, "Python")) shprint(sh.make, self.ctx.concurrent_make, "-C", build_dir, "bininstall", "inclinstall", _env=build_env) pylib_dir = join(self.ctx.dist_dir, "hostpython2", "lib", "python2.7") if exists(pylib_dir): shutil.rmtree(pylib_dir) shutil.copytree(join(build_dir, "Lib"), pylib_dir) ensure_dir(join(pylib_dir, "config")) shutil.copy(join(build_dir, "Makefile"), join(pylib_dir, "config", "Makefile")) shutil.copy(join(build_dir, "Parser", "pgen"), join(self.ctx.dist_dir, "hostpython2", "bin", "pgen"))
def build_arch(self, arch): build_env = self.get_pil_env(arch) hostpython3 = sh.Command(self.ctx.hostpython) shprint(hostpython3, "setup.py", "build_ext", "--disable-tiff", "--disable-webp", "--disable-lcms", "--disable-webpmux", "--disable-jpeg2000", "--disable-imagequant", "-g", _env=build_env) self.biglink()
def install_python_package(self, name=None, env=None, is_dir=True): """Automate the installation of a Python package into the target site-packages. It will works with the first filtered_archs, and the name of the recipe. """ arch = self.filtered_archs[0] if name is None: name = self.name if env is None: env = self.get_recipe_env(arch) print("Install {} into the site-packages".format(name)) build_dir = self.get_build_dir(arch.arch) chdir(build_dir) hostpython = sh.Command( join(self.ctx.dist_dir, "hostpython", "bin", "python")) iosbuild = join(build_dir, "iosbuild") shprint(hostpython, "setup.py", "install", "-O2", "--prefix", iosbuild, _env=env) dest_dir = join(self.ctx.site_packages_dir, name) self.remove_junk(iosbuild) if is_dir: if exists(dest_dir): shutil.rmtree(dest_dir) func = shutil.copytree else: func = shutil.copy func( join(iosbuild, "lib", self.ctx.python_ver_dir, "site-packages", name), dest_dir)
def build_x86_64(self): sdk_path = sh.xcrun("--sdk", "macosx", "--show-sdk-path").strip() build_env = self.ctx.env.copy() ccache = (build_env["CCACHE"] + ' ') if 'CCACHE' in build_env else '' build_env[ "CC"] = ccache + "clang -Qunused-arguments -fcolor-diagnostics" build_env["LDFLAGS"] = " ".join([ "-lsqlite3", "-lffi", "-L{}".format( join(self.ctx.dist_dir, "hostlibffi", "usr", "local", "lib")) ]) build_env["CFLAGS"] = " ".join([ "--sysroot={}".format(sdk_path), "-I{}".format( join(self.ctx.dist_dir, "hostlibffi", "usr", "local", "include")) ]) if "openssl.build_all" in self.ctx.state: build_env["CFLAGS"] += " -I{}".format( join(self.ctx.dist_dir, "include", "x86_64", "openssl")) configure = sh.Command(join(self.build_dir, "configure")) shprint(configure, "--prefix={}".format(join(self.ctx.dist_dir, "hostpython")), "--disable-toolbox-glue", "--without-gcc", _env=build_env) shprint(sh.make, "-C", self.build_dir, "-j4", "python", "Parser/pgen", _env=build_env) shutil.move("python", "hostpython") shutil.move("Parser/pgen", "Parser/hostpgen")
def build_x86_64(self): sdk_path = sh.xcrun("--sdk", "macosx", "--show-sdk-path").strip() build_env = self.ctx.env.copy() ccache = (build_env["CCACHE"] + ' ') if 'CCACHE' in build_env else '' build_env["CC"] = ccache + "clang -Qunused-arguments -fcolor-diagnostics" build_env["LDFLAGS"] = " ".join([ "-lsqlite3", "-lffi", "-L{}".format(join(self.ctx.dist_dir, "hostlibffi", "usr", "local", "lib")) ]) build_env["CFLAGS"] = " ".join([ "--sysroot={}".format(sdk_path), "-I{}".format(join(self.ctx.dist_dir, "hostlibffi", "usr", "local", "include")) ]) if "openssl.build_all" in self.ctx.state: build_env["CFLAGS"] += " -I{}".format(join(self.ctx.dist_dir, "include", "x86_64", "openssl")) configure = sh.Command(join(self.build_dir, "configure")) shprint(configure, "--prefix={}".format(join(self.ctx.dist_dir, "hostpython")), "--disable-toolbox-glue", "--without-gcc", _env=build_env) shprint(sh.make, "-C", self.build_dir, self.ctx.concurrent_make, "python", "Parser/pgen", _env=build_env) shutil.move("python", "hostpython") shutil.move("Parser/pgen", "Parser/hostpgen")
def build_arch(self, arch): shprint(sh.xcodebuild, "ONLY_ACTIVE_ARCH=NO", "ARCHS={}".format(arch.arch), "-sdk", arch.sdk, "-project", "Xcode-iOS/SDL/SDL.xcodeproj", "-target", "libSDL", "-configuration", "Release")
def prebuild_arch(self, arch): hostpython = sh.Command(self.ctx.hostpython) sh.curl("-O", "https://bootstrap.pypa.io/ez_setup.py") dest_dir = join(self.ctx.dist_dir, "root", "python") build_env = arch.get_env() build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python2.7', 'site-packages') # shprint(hostpython, "./ez_setup.py", "--to-dir", dest_dir) shprint(hostpython, "./ez_setup.py", _env=build_env)
def build_arch(self, arch): shprint(sh.xcodebuild, "ONLY_ACTIVE_ARCH=NO", "ARCHS={}".format(arch.arch), "-sdk", arch.sdk, "-project", "libffi.xcodeproj", "-target", "libffi-iOS", "-configuration", "Release")
def install(self): arch = list(self.filtered_archs)[0] build_dir = self.get_build_dir(arch.arch) os.chdir(build_dir) hostpython = sh.Command(self.ctx.hostpython) build_env = arch.get_env() dest_dir = join(self.ctx.dist_dir, "root", "python") build_env['PYTHONPATH'] = join(dest_dir, 'lib', 'python2.7', 'site-packages') shprint(hostpython, "setup.py", "install", "--prefix", dest_dir, _env=build_env)
def build_arch(self, arch): shprint(sh.xcodebuild, self.ctx.concurrent_xcodebuild, "ONLY_ACTIVE_ARCH=NO", "ARCHS={}".format(arch.arch), "HEADER_SEARCH_PATHS=$HEADER_SEARCH_PATHS {}".format(" ".join(arch.include_dirs)), "-sdk", arch.sdk, "-project", "Xcode-iOS/SDL_mixer.xcodeproj", "-target", "Static Library", "-configuration", "Release")
def build_arch(self, arch): self.apply_patch('pil_setup.patch') build_env = self.get_pil_env(arch) #build_dir = self.get_build_dir(arch.arch) hostpython = sh.Command(self.ctx.hostpython) #build_env["PYTHONHOME"] = hostpython # first try to generate .h shprint(hostpython, "setup.py", "build_ext", "-g", _env=build_env) self.biglink()
def prebuild_arch(self, arch): if self.has_marker("patched"): return # XCode 10 minimum is 8.0 now. shprint(sh.sed, "-i.bak", "s/-miphoneos-version-min=5.1.1/-miphoneos-version-min=8.0/g", "generate-darwin-source-and-headers.py") self.apply_patch("fix-win32-unreferenced-symbol.patch") self.set_marker("patched")
def reduce_python(self): logger.info("Reduce python") oldpwd = os.getcwd() try: logger.info("Remove files unlikely to be used") os.chdir(join(self.ctx.dist_dir, "root", "python3")) # os.execve("/bin/bash", ["/bin/bash"], env=os.environ) sh.rm("-rf", "bin", "share") # platform binaries and configuration os.chdir(join( self.ctx.dist_dir, "root", "python3", "lib", "python3.7", "config-3.7m-darwin")) sh.rm("libpython3.7m.a") sh.rm("python.o") sh.rm("config.c.in") sh.rm("makesetup") sh.rm("install-sh") # cleanup pkgconfig and compiled lib os.chdir(join(self.ctx.dist_dir, "root", "python3", "lib")) sh.rm("-rf", "pkgconfig") sh.rm("-f", "libpython3.7m.a") # cleanup python libraries os.chdir(join( self.ctx.dist_dir, "root", "python3", "lib", "python3.7")) sh.rm("-rf", "wsgiref", "curses", "idlelib", "lib2to3", "ensurepip", "turtledemo", "lib-dynload", "venv", "pydoc_data") sh.find(".", "-path", "*/test*/*", "-delete") sh.find(".", "-name", "*.exe", "-type", "f", "-delete") sh.find(".", "-name", "test*", "-type", "d", "-delete") sh.find(".", "-iname", "*.pyc", "-delete") sh.find(".", "-path", "*/__pycache__/*", "-delete") sh.find(".", "-name", "__pycache__", "-type", "d", "-delete") # now precompile to Python bytecode hostpython = sh.Command(self.ctx.hostpython) shprint(hostpython, "-m", "compileall", "-f", "-b") # sh.find(".", "-iname", "*.py", "-delete") # some pycache are recreated after compileall sh.find(".", "-path", "*/__pycache__/*", "-delete") sh.find(".", "-name", "__pycache__", "-type", "d", "-delete") # create the lib zip logger.info("Create a python3.7.zip") sh.mv("config-3.7m-darwin", "..") sh.mv("site-packages", "..") sh.zip("-r", "../python37.zip", sh.glob("*")) sh.rm("-rf", sh.glob("*")) sh.mv("../config-3.7m-darwin", ".") sh.mv("../site-packages", ".") finally: os.chdir(oldpwd)
def build_arch(self, arch): shprint(sh.xcodebuild, "ONLY_ACTIVE_ARCH=NO", "ARCHS={}".format(arch.arch), "HEADER_SEARCH_PATHS={}".format( join(self.ctx.include_dir, "common", "sdl2")), "-sdk", arch.sdk, "-project", "Xcode-iOS/SDL_image.xcodeproj", "-target", "libSDL_image", "-configuration", "Release")
def build_x86_64(self): build_env = self.get_build_env() configure = sh.Command(join(self.build_dir, "configure")) shprint(configure, "--prefix={}".format(join(self.ctx.dist_dir, "hostpython3")), # "--disable-toolbox-glue", # "--without-gcc", _env=build_env) shprint(sh.make, "-C", self.build_dir, self.ctx.concurrent_make, _env=build_env)
def prebuild_arch(self, arch): if self.has_marker("patched"): return # necessary as it doesn't compile with XCode 6.0. If we use 5.1.1, the # compiler for i386 is not working. shprint(sh.sed, "-i.bak", "s/-miphoneos-version-min=5.1.1/-miphoneos-version-min=6.0/g", "generate-darwin-source-and-headers.py") self.apply_patch("fix-win32-unreferenced-symbol.patch") self.set_marker("patched")
def build_arch(self, arch): env = arch.get_env() shprint(sh.xcodebuild, "ONLY_ACTIVE_ARCH=NO", "ARCHS={}".format(arch.arch), "CC={}".format(env['CC']), "-sdk", arch.sdk, "-project", "Xcode-iOS/SDL/SDL.xcodeproj", "-target", "libSDL", "-configuration", "Release")
def build_arch(self, arch): shprint(sh.xcodebuild, self.ctx.concurrent_xcodebuild, "ONLY_ACTIVE_ARCH=NO", "ARCHS={}".format(arch.arch), "-sdk", "macosx", "install", "installhdrs", "-project", "libffi.xcodeproj", "-target", "libffi-Mac", "-configuration", "Release", "DSTROOT={}/hostlibffi".format(self.ctx.dist_dir))
def build_arch(self, arch): build_env = self.get_build_env(arch) configure = sh.Command(join(self.build_dir, "configure")) py_arch = arch.arch if py_arch == "armv7": py_arch = "arm" elif py_arch == "arm64": py_arch = "aarch64" prefix = join(self.ctx.dist_dir, "root", "python3") shprint( configure, "CC={}".format(build_env["CC"]), "LD={}".format(build_env["LD"]), "CFLAGS={}".format(build_env["CFLAGS"]), "LDFLAGS={} -undefined dynamic_lookup".format( build_env["LDFLAGS"]), # "--without-pymalloc", "ac_cv_file__dev_ptmx=yes", "ac_cv_file__dev_ptc=no", "ac_cv_little_endian_double=yes", "ac_cv_func_memrchr=no", "ac_cv_func_getentropy=no", "ac_cv_func_getresuid=no", "ac_cv_func_getresgid=no", "ac_cv_func_setresgid=no", "ac_cv_func_setresuid=no", "ac_cv_func_plock=no", "ac_cv_func_dup3=no", "ac_cv_func_pipe2=no", "ac_cv_func_preadv=no", "ac_cv_func_pwritev=no", "ac_cv_func_preadv2=no", "ac_cv_func_pwritev2=no", "ac_cv_func_mkfifoat=no", "ac_cv_func_mknodat=no", "ac_cv_func_posix_fadvise=no", "ac_cv_func_posix_fallocate=no", "ac_cv_func_sigwaitinfo=no", "ac_cv_func_sigtimedwait=no", "ac_cv_func_clock_settime=no", "ac_cv_func_pthread_getcpuclockid=no", "ac_cv_func_sched_setscheduler=no", "ac_cv_func_sched_setparam=no", "ac_cv_func_clock_gettime=no", "--host={}-apple-ios".format(py_arch), "--build=x86_64-apple-darwin", "--prefix={}".format(prefix), "--without-ensurepip", "--with-system-ffi", # "--without-doc-strings", "--enable-ipv6", _env=build_env) self.apply_patch("ctypes_duplicate.patch") shprint(sh.make, self.ctx.concurrent_make)
def build_arch(self, arch): build_env = self.get_build_env(arch) configure = sh.Command(join(self.build_dir, "configure")) py_arch = arch.arch if py_arch == "armv7": py_arch = "arm" elif py_arch == "arm64": py_arch = "aarch64" prefix = join(self.ctx.dist_dir, "root", "python3") shprint(configure, "CC={}".format(build_env["CC"]), "LD={}".format(build_env["LD"]), "CFLAGS={}".format(build_env["CFLAGS"]), "LDFLAGS={} -undefined dynamic_lookup".format(build_env["LDFLAGS"]), "ac_cv_file__dev_ptmx=yes", "ac_cv_file__dev_ptc=no", "ac_cv_little_endian_double=yes", "ac_cv_func_memrchr=no", "ac_cv_func_getentropy=no", "ac_cv_func_getresuid=no", "ac_cv_func_getresgid=no", "ac_cv_func_setresgid=no", "ac_cv_func_setresuid=no", "ac_cv_func_plock=no", "ac_cv_func_dup3=no", "ac_cv_func_pipe2=no", "ac_cv_func_preadv=no", "ac_cv_func_pwritev=no", "ac_cv_func_preadv2=no", "ac_cv_func_pwritev2=no", "ac_cv_func_mkfifoat=no", "ac_cv_func_mknodat=no", "ac_cv_func_posix_fadvise=no", "ac_cv_func_posix_fallocate=no", "ac_cv_func_sigwaitinfo=no", "ac_cv_func_sigtimedwait=no", "ac_cv_func_clock_settime=no", "ac_cv_func_pthread_getcpuclockid=no", "ac_cv_func_sched_setscheduler=no", "ac_cv_func_sched_setparam=no", "ac_cv_func_clock_gettime=no", "--host={}-apple-ios".format(py_arch), "--build=x86_64-apple-darwin", "--prefix={}".format(prefix), "--without-ensurepip", "--with-system-ffi", "--enable-ipv6", "PYTHON_FOR_BUILD=_PYTHON_PROJECT_BASE=$(abs_builddir) \ _PYTHON_HOST_PLATFORM=$(_PYTHON_HOST_PLATFORM) \ PYTHONPATH=$(shell test -f pybuilddir.txt && echo $(abs_builddir)/`cat pybuilddir.txt`:)$(srcdir)/Lib\ _PYTHON_SYSCONFIGDATA_NAME=_sysconfigdata_$(ABIFLAGS)_$(MACHDEP)_$(MULTIARCH)\ {}".format(sh.Command(self.ctx.hostpython)), _env=build_env) self.apply_patch("ctypes_duplicate.patch") shprint(sh.make, self.ctx.concurrent_make)
def install(self): arch = list(self.filtered_archs)[0] build_env = self.get_build_env(arch) build_dir = self.get_build_dir(arch.arch) shprint(sh.make, self.ctx.concurrent_make, "-C", build_dir, "install", "prefix={}".format(join(self.ctx.dist_dir, "root", "python3")), _env=build_env) # os.execve("/bin/bash", ["/bin/bash"], os.environ) self.reduce_python()
def build_arch(self, arch): # XCode-iOS have shipped freetype that don't work with i386 # ./configure require too much things to setup it correcly. # so build by hand. build_env = arch.get_env() cc = sh.Command(build_env["CC"]) output = join(self.build_dir, "SDL_ttf.o") args = shlex.split(build_env["CFLAGS"]) args += ["-c", "-o", output, "SDL_ttf.c"] shprint(cc, *args) shprint(sh.ar, "-q", join(self.build_dir, "libSDL2_ttf.a"), output)
def build_arch(self, arch): build_env = self.get_build_env(arch) configure = sh.Command(join(self.build_dir, "configure")) py_arch = arch.arch if py_arch == "armv7": py_arch = "arm" elif py_arch == "arm64": py_arch = "aarch64" prefix = join(self.ctx.dist_dir, "root", "python3") shprint(configure, "CC={}".format(build_env["CC"]), "LD={}".format(build_env["LD"]), "CFLAGS={}".format(build_env["CFLAGS"]), "LDFLAGS={} -undefined dynamic_lookup".format(build_env["LDFLAGS"]), # "--without-pymalloc", "ac_cv_file__dev_ptmx=yes", "ac_cv_file__dev_ptc=no", "ac_cv_little_endian_double=yes", "ac_cv_func_memrchr=no", "ac_cv_func_getentropy=no", "ac_cv_func_getresuid=no", "ac_cv_func_getresgid=no", "ac_cv_func_setresgid=no", "ac_cv_func_setresuid=no", "ac_cv_func_plock=no", "ac_cv_func_dup3=no", "ac_cv_func_pipe2=no", "ac_cv_func_preadv=no", "ac_cv_func_pwritev=no", "ac_cv_func_preadv2=no", "ac_cv_func_pwritev2=no", "ac_cv_func_mkfifoat=no", "ac_cv_func_mknodat=no", "ac_cv_func_posix_fadvise=no", "ac_cv_func_posix_fallocate=no", "ac_cv_func_sigwaitinfo=no", "ac_cv_func_sigtimedwait=no", "ac_cv_func_clock_settime=no", "ac_cv_func_pthread_getcpuclockid=no", "ac_cv_func_sched_setscheduler=no", "ac_cv_func_sched_setparam=no", "ac_cv_func_clock_gettime=no", "--host={}-apple-ios".format(py_arch), "--build=x86_64-apple-darwin", "--prefix={}".format(prefix), "--without-ensurepip", "--with-system-ffi", # "--without-doc-strings", "--enable-ipv6", _env=build_env) self.apply_patch("ctypes_duplicate.patch") shprint(sh.make, self.ctx.concurrent_make)
def install(self): arch = list(self.filtered_archs)[0] build_env = arch.get_env() build_dir = self.get_build_dir(arch.arch) build_env["PATH"] = os.environ["PATH"] shprint(sh.make, "-C", build_dir, "bininstall", "inclinstall", _env=build_env) pylib_dir = join(self.ctx.dist_dir, "hostpython", "lib", "python2.7") if exists(pylib_dir): shutil.rmtree(pylib_dir) shutil.copytree(join(build_dir, "Lib"), pylib_dir) ensure_dir(join(pylib_dir, "config")) shutil.copy(join(build_dir, "Makefile"), join(pylib_dir, "config", "Makefile")) shutil.copy(join(build_dir, "Parser", "pgen"), join(self.ctx.dist_dir, "hostpython", "bin", "pgen"))
def install(self): arch = list(self.filtered_archs)[0] build_env = arch.get_env() build_dir = self.get_build_dir(arch.arch) build_env["PATH"] = os.environ["PATH"] shprint(sh.make, "-C", build_dir, "install", "CROSS_COMPILE_TARGET=yes", "HOSTPYTHON={}".format(self.ctx.hostpython), "prefix={}".format(join(self.ctx.dist_dir, "root", "python")), _env=build_env) self.reduce_python()
def build_arch(self, arch): build_env = arch.get_env() self.apply_patch('hash_SHA2_template.c.patch', target_dir=self.build_dir + '/src') configure = sh.Command(join(self.build_dir, "configure")) shprint(configure, "CC={}".format(build_env["CC"]), "LD={}".format(build_env["LD"]), "CFLAGS={}".format(build_env["CFLAGS"]), "LDFLAGS={} -Wno-error ".format(build_env["LDFLAGS"]), "--prefix=/", "--host={}".format(arch), "ac_cv_func_malloc_0_nonnull=yes", "ac_cv_func_realloc_0_nonnull=yes", ) hostpython = sh.Command(self.ctx.hostpython) super(PycryptoRecipe, self).build_arch(arch)
def build_i386(self): sdk_path = sh.xcrun("--sdk", "macosx", "--show-sdk-path").strip() build_env = self.ctx.env.copy() build_env["CC"] = "clang -Qunused-arguments -fcolor-diagnostics" build_env["LDFLAGS"] = " ".join(["-lsqlite3", "-lffi", "-L{}".format(join(self.ctx.dist_dir, "lib"))]) build_env["CFLAGS"] = " ".join( ["--sysroot={}".format(sdk_path), "-I{}".format(join(self.ctx.dist_dir, "include", "i386", "libffi"))] ) configure = sh.Command(join(self.build_dir, "configure")) shprint( configure, "--prefix={}".format(join(self.ctx.dist_dir, "hostpython")), "--disable-toolbox-glue", "--without-gcc", _env=build_env, ) shprint(sh.make, "-C", self.build_dir, "-j4", "python.exe", "Parser/pgen", _env=build_env) shutil.move("python.exe", "hostpython") shutil.move("Parser/pgen", "Parser/hostpgen")
def prebuild_arch(self, arch): hostpython = sh.Command(self.ctx.hostpython) sh.curl("-O", "https://bootstrap.pypa.io/ez_setup.py") shprint(hostpython, "./ez_setup.py") # Extract setuptools egg and remove .pth files. Otherwise subsequent # python package installations using setuptools will raise exceptions. # Setuptools version 28.3.0 site_packages_path = join( self.ctx.dist_dir, 'hostpython', 'lib', 'python2.7', 'site-packages') os.chdir(site_packages_path) with open('setuptools.pth', 'r') as f: setuptools_egg_path = f.read().strip('./').strip('\n') unzip = sh.Command('unzip') shprint(unzip, setuptools_egg_path) os.remove(setuptools_egg_path) os.remove('setuptools.pth') os.remove('easy-install.pth') shutil.rmtree('EGG-INFO')
def build_arch(self, arch): options_iphoneos = ( "-isysroot {}".format(arch.sysroot), "-DOPENSSL_THREADS", "-D_REENTRANT", "-DDSO_DLFCN", "-DHAVE_DLFCN_H", "-fomit-frame-pointer", "-fno-common", "-O3" ) build_env = arch.get_env() target = arch_mapper[arch.arch] shprint(sh.env, _env=build_env) sh.perl(join(self.build_dir, "Configure"), target, _env=build_env) if target == 'iphoneos-cross': sh.sed("-ie", "s!^CFLAG=.*!CFLAG={} {}!".format(build_env['CFLAGS'], " ".join(options_iphoneos)), "Makefile") sh.sed("-ie", "s!static volatile sig_atomic_t intr_signal;!static volatile intr_signal;! ", "crypto/ui/ui_openssl.c") else: sh.sed("-ie", "s!^CFLAG=!CFLAG={} !".format(build_env['CFLAGS']), "Makefile") shprint(sh.make, "clean") shprint(sh.make, "-j4", "build_libs")
def build_arch(self, arch): if exists("generate-darwin-source-and-headers.py"): shprint( sh.mv, "generate-darwin-source-and-headers.py", "_generate-darwin-source-and-headers.py") shprint(sh.touch, "generate-darwin-source-and-headers.py") python27 = sh.Command("python2.7") shprint(python27, "_generate-darwin-source-and-headers.py", "--only-ios") shprint(sh.xcodebuild, self.ctx.concurrent_xcodebuild, "ONLY_ACTIVE_ARCH=NO", "ARCHS={}".format(arch.arch), "-sdk", arch.sdk, "-project", "libffi.xcodeproj", "-target", "libffi-iOS", "-configuration", "Release")
def build_arch(self, arch): if exists("generate-darwin-source-and-headers.py"): shprint( sh.mv, "generate-darwin-source-and-headers.py", "_generate-darwin-source-and-headers.py") shprint(sh.touch, "generate-darwin-source-and-headers.py") python27 = sh.Command("python2.7") shprint(python27, "_generate-darwin-source-and-headers.py", "--only-osx") shprint(sh.xcodebuild, self.ctx.concurrent_xcodebuild, "ONLY_ACTIVE_ARCH=NO", "ARCHS={}".format(arch.arch), "DSTROOT={}/hostlibffi".format(self.ctx.dist_dir), "-sdk", "macosx", "clean", "build", "installhdrs", "install", "-project", "libffi.xcodeproj", "-scheme", "libffi-Mac", "-configuration", "Release")