From d4c1ac88d7a477e42df656d3c54a760b6e1ba7d3 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Tue, 3 Feb 2015 00:19:53 +0100 Subject: [PATCH] remove unused recipes and work on host python / python / lib --- recipes/audiostream.py | 7 - recipes/hostpython/ModulesSetup | 52 ++++++ recipes/hostpython/__init__.py | 47 +++++ recipes/hostpython/dynload.patch | 24 +++ recipes/hostpython/ssize-t-max.patch | 17 ++ recipes/hostpython/static-_sqlite3.patch | 25 +++ recipes/libffi/__init__.py | 48 ++++-- recipes/python/__init__.py | 62 ++----- recipes/python/__init__.pyc | Bin 4163 -> 2751 bytes toolchain.py | 210 +++++++++++++++++++---- 10 files changed, 381 insertions(+), 111 deletions(-) delete mode 100644 recipes/audiostream.py create mode 100644 recipes/hostpython/ModulesSetup create mode 100644 recipes/hostpython/__init__.py create mode 100644 recipes/hostpython/dynload.patch create mode 100644 recipes/hostpython/ssize-t-max.patch create mode 100644 recipes/hostpython/static-_sqlite3.patch diff --git a/recipes/audiostream.py b/recipes/audiostream.py deleted file mode 100644 index 51fded8..0000000 --- a/recipes/audiostream.py +++ /dev/null @@ -1,7 +0,0 @@ -from toolchain import Recipe - -class AudiostreamRecipe(Recipe): - version = "master" - url = "https://github.com/kivy/audiostream/archive/{version}.zip" - -recipe = AudiostreamRecipe() diff --git a/recipes/hostpython/ModulesSetup b/recipes/hostpython/ModulesSetup new file mode 100644 index 0000000..77a934a --- /dev/null +++ b/recipes/hostpython/ModulesSetup @@ -0,0 +1,52 @@ +posix posixmodule.c # posix (UNIX) system calls +errno errnomodule.c # posix (UNIX) errno values +pwd pwdmodule.c # this is needed to find out the user's home dir + # if $HOME is not set +_sre _sre.c # Fredrik Lundh's new regular expressions +_codecs _codecsmodule.c # access to the builtin codecs and codec registry +zipimport zipimport.c +_symtable symtablemodule.c +array arraymodule.c # array objects +cmath cmathmodule.c # -lm # complex math library functions +math mathmodule.c # -lm # math library functions, e.g. sin() +_struct _struct.c # binary structure packing/unpacking +time timemodule.c # -lm # time operations and variables +operator operator.c # operator.add() and similar goodies +_weakref _weakref.c # basic weak reference support +_random _randommodule.c # Random number generator +_collections _collectionsmodule.c # Container types +itertools itertoolsmodule.c # Functions creating iterators for efficient looping +strop stropmodule.c # String manipulations +_functools _functoolsmodule.c # Tools for working with functions and callable objects +_elementtree -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI _elementtree.c # elementtree accelerator +datetime datetimemodule.c # date/time type +_bisect _bisectmodule.c # Bisection algorithms +fcntl fcntlmodule.c # fcntl(2) and ioctl(2) +select selectmodule.c # select(2); not on ancient System V +_socket socketmodule.c +_md5 md5module.c md5.c +_sha shamodule.c +_sha256 sha256module.c +_sha512 sha512module.c +binascii binascii.c +parser parsermodule.c +cStringIO cStringIO.c +cPickle cPickle.c +zlib zlibmodule.c -I$(prefix)/include -L$(exec_prefix)/lib -lz +xxsubtype xxsubtype.c +unicodedata unicodedata.c # static Unicode character database + +# Theses modules are used by Kivy inside other module +# json in Settings, _io by zipfile... +_json _json.c +_io _io/bufferedio.c _io/bytesio.c _io/fileio.c _io/iobase.c _io/_iomodule.c _io/stringio.c _io/textio.c +_heapq _heapqmodule.c + +# Special inclusion for sqlite3 +_sqlite3 -DSQLITE_OMIT_LOAD_EXTENSION _sqlite/cache.c _sqlite/microprotocols.c _sqlite/row.c _sqlite/connection.c _sqlite/module.c _sqlite/statement.c _sqlite/cursor.c _sqlite/prepare_protocol.c _sqlite/util.c + +# Include expat +pyexpat expat/xmlparse.c expat/xmlrole.c expat/xmltok.c pyexpat.c -I$(srcdir)/Modules/expat -DHAVE_EXPAT_CONFIG_H -DUSE_PYEXPAT_CAPI + +# Future (used by numpy) +future_builtins future_builtins.c diff --git a/recipes/hostpython/__init__.py b/recipes/hostpython/__init__.py new file mode 100644 index 0000000..bd742a7 --- /dev/null +++ b/recipes/hostpython/__init__.py @@ -0,0 +1,47 @@ +from toolchain import Recipe, shprint +from os.path import join +import sh +import shutil + + +class HostpythonRecipe(Recipe): + version = "2.7.1" + url = "https://www.python.org/ftp/python/{version}/Python-{version}.tar.bz2" + depends = ["libffi", ] + archs = ["i386"] + + def download(self): + super(HostpythonRecipe, self).download() + self.ctx.hostpython = join( + self.ctx.build_dir, "i386", self.archive_root, + "hostpython") + self.ctx.hostpgen = join( + self.ctx.build_dir, "i386", self.archive_root, + "Parser", "hostpgen") + print("Global: hostpython located at {}".format(self.ctx.hostpython)) + print("Global: hostpgen located at {}".format(self.ctx.hostpgen)) + + def prebuild_arch(self, arch): + if self.has_marker("patched"): + return + self.apply_patch("ssize-t-max.patch") + self.apply_patch("dynload.patch") + self.apply_patch("static-_sqlite3.patch") + self.copy_file("ModulesSetup", "Modules/Setup.local") + self.set_marker("patched") + + 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"] = "-lsqlite3" + build_env["CFLAGS"] = "--sysroot={}".format(sdk_path) + configure = sh.Command(join(self.build_dir, "configure")) + shprint(configure, _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") + +recipe = HostpythonRecipe() diff --git a/recipes/hostpython/dynload.patch b/recipes/hostpython/dynload.patch new file mode 100644 index 0000000..7cb73f6 --- /dev/null +++ b/recipes/hostpython/dynload.patch @@ -0,0 +1,24 @@ +--- Python-2.7.1/Python/dynload_shlib.c.orig 2011-12-05 00:00:00.000000000 +0100 ++++ Python-2.7.1/Python/dynload_shlib.c 2011-12-05 00:02:51.000000000 +0100 +@@ -84,6 +84,15 @@ + PyOS_snprintf(funcname, sizeof(funcname), + LEAD_UNDERSCORE "init%.200s", shortname); + ++ /* On IOS, dlopen crash as soon as we try to open one of our library. ++ * Instead, we have done a redirection of linking to convert our .so into a ++ * .a. Then the main executable is linked with theses symbol. So, instead ++ * of trying to dlopen, directly do the dlsym. ++ * -- Mathieu ++ */ ++ return (dl_funcptr) dlsym(RTLD_MAIN_ONLY, funcname); ++ ++#if 0 + if (fp != NULL) { + int i; + struct stat statb; +@@ -140,4 +149,5 @@ + handles[nhandles++].handle = handle; + p = (dl_funcptr) dlsym(handle, funcname); + return p; ++#endif + } diff --git a/recipes/hostpython/ssize-t-max.patch b/recipes/hostpython/ssize-t-max.patch new file mode 100644 index 0000000..3d63b49 --- /dev/null +++ b/recipes/hostpython/ssize-t-max.patch @@ -0,0 +1,17 @@ +diff -Naur Python-2.7.1.orig/Include/pyport.h Python-2.7.1/Include/pyport.h +--- Python-2.7.1.orig/Include/pyport.h 2010-09-14 18:10:22.000000000 +0200 ++++ Python-2.7.1/Include/pyport.h 2011-05-13 12:24:53.000000000 +0200 +@@ -186,9 +186,11 @@ + #endif + + /* Largest positive value of type Py_ssize_t. */ +-#define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1)) ++//#define PY_SSIZE_T_MAX ((Py_ssize_t)(((size_t)-1)>>1)) + /* Smallest negative value of type Py_ssize_t. */ +-#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1) ++//#define PY_SSIZE_T_MIN (-PY_SSIZE_T_MAX-1) ++#define PY_SSIZE_T_MAX TMP_MAX ++#define PY_SSIZE_T_MIN -TMP_MAX + + #if SIZEOF_PID_T > SIZEOF_LONG + # error "Python doesn't support sizeof(pid_t) > sizeof(long)" diff --git a/recipes/hostpython/static-_sqlite3.patch b/recipes/hostpython/static-_sqlite3.patch new file mode 100644 index 0000000..783c5ef --- /dev/null +++ b/recipes/hostpython/static-_sqlite3.patch @@ -0,0 +1,25 @@ +--- Python-2.7.1/Modules/_sqlite/module.c.orig 2012-10-28 02:30:58.000000000 +0200 ++++ Python-2.7.1/Modules/_sqlite/module.c 2012-10-28 02:28:12.000000000 +0200 +@@ -28,6 +28,9 @@ + #include "prepare_protocol.h" + #include "microprotocols.h" + #include "row.h" ++#ifndef MODULE_NAME ++#define MODULE_NAME "_sqlite3" ++#endif + + #if SQLITE_VERSION_NUMBER >= 3003003 + #define HAVE_SHARED_CACHE +--- Python-2.7.1/Modules/_sqlite/sqlitecompat.h.orig 2012-10-28 02:30:53.000000000 +0200 ++++ Python-2.7.1/Modules/_sqlite/sqlitecompat.h 2012-10-28 02:28:14.000000000 +0200 +@@ -26,6 +26,10 @@ + #ifndef PYSQLITE_COMPAT_H + #define PYSQLITE_COMPAT_H + ++#ifndef MODULE_NAME ++#define MODULE_NAME "_sqlite3" ++#endif ++ + /* define Py_ssize_t for pre-2.5 versions of Python */ + + #if PY_VERSION_HEX < 0x02050000 diff --git a/recipes/libffi/__init__.py b/recipes/libffi/__init__.py index b738c09..3a70617 100644 --- a/recipes/libffi/__init__.py +++ b/recipes/libffi/__init__.py @@ -1,33 +1,49 @@ from toolchain import Recipe, shprint +from os.path import join, exists import sh +import shutil class LibffiRecipe(Recipe): - version = "3.0.13" + version = "3.2.1" url = "ftp://sourceware.org/pub/libffi/libffi-{version}.tar.gz" + archs = ("armv7",) def prebuild_arch(self, arch): if self.has_marker("patched"): return - self.apply_patch("ffi-3.0.13-sysv.S.patch") - if arch in ("armv7", "armv7s", "arm64"): - shprint(sh.sed, - "-i.bak", - "s/-miphoneos-version-min=4.0/-miphoneos-version-min=6.0/g", - "generate-ios-source-and-headers.py") + # 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.set_marker("patched") def build_arch(self, arch): - if arch == "i386": - target_name = "libffi OS X" - else: - target_name = "libffi iOS" - shprint(sh.xcodebuild, "-project", "libffi.xcodeproj", - "-target", target_name, - "-configuration", "Release", - "-sdk", "iphoneos{}".format(self.ctx.sdkver), - "OTHER_CFLAGS=-no-integrated-as") + "-target", "libffi-iOS", + "-configuration", "Release") + + def assemble_to(self, filename): + shutil.copy(join( + self.get_build_dir("armv7"), + "build/Release-iphoneos/libffi.a"), + filename) + for sdkarch, arch in ( + ("iphoneos-arm64", "arm64"), + ("iphoneos-armv7", "armv7"), + ("iphonesimulator-i386", "i386"), + ("iphonesimulator-x86_64", "x86_64")): + dest_dir = join(self.ctx.dist_dir, "include", arch, "ffi") + if exists(dest_dir): + continue + shutil.copytree(join( + self.get_build_dir("armv7"), + "build_{}/include".format(sdkarch)), + join(self.ctx.dist_dir, "include", arch, "ffi")) + recipe = LibffiRecipe() + diff --git a/recipes/python/__init__.py b/recipes/python/__init__.py index 83622a6..a9ac8f4 100644 --- a/recipes/python/__init__.py +++ b/recipes/python/__init__.py @@ -1,24 +1,12 @@ from toolchain import Recipe, shprint from os.path import join import sh -import shutil class PythonRecipe(Recipe): version = "2.7.1" url = "https://www.python.org/ftp/python/{version}/Python-{version}.tar.bz2" - depends = ["libffi", ] - - def download(self): - super(PythonRecipe, self).download() - self.ctx.hostpython = join( - self.ctx.build_dir, "i386", self.archive_root, - "hostpython") - self.ctx.hostpgen = join( - self.ctx.build_dir, "i386", self.archive_root, - "Parser", "hostpgen") - print("Global: hostpython located at {}".format(self.ctx.hostpython)) - print("Global: hostpgen located at {}".format(self.ctx.hostpgen)) + depends = ["hostpython", "libffi", ] def prebuild_arch(self, arch): # common to all archs @@ -29,56 +17,30 @@ class PythonRecipe(Recipe): self.apply_patch("static-_sqlite3.patch") self.copy_file("ModulesSetup", "Modules/Setup.local") self.copy_file("_scproxy.py", "Lib/_scproxy.py") - #self.copy_file("Setup.dist", "Modules/Setup.dist") - - if arch in ("armv7", "armv7s", "arm64"): - self.apply_patch("xcompile.patch") - self.apply_patch("setuppath.patch") - self.append_file("ModulesSetup.mobile", "Modules/Setup.local") + self.apply_patch("xcompile.patch") + self.apply_patch("setuppath.patch") + self.append_file("ModulesSetup.mobile", "Modules/Setup.local") self.set_marker("patched") - def build_i386(self): - sdk_path = sh.xcrun( - "--sdk", "macosx", - "--show-sdk-path").splitlines()[0] - - build_env = self.ctx.env.copy() - build_env["CC"] = "clang -Qunused-arguments -fcolor-diagnostics" - build_env["LDFLAGS"] = "-lsqlite3" - build_env["CFLAGS"] = "--sysroot={}".format(sdk_path) - configure = sh.Command(join(self.build_dir, "configure")) - shprint(configure, _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): - if self.has_marker("build"): - return - if arch == "i386": - super(PythonRecipe, self).build_arch(arch) - self.set_marker("build") - return - build_env = self.ctx.env.copy() - build_env["CC"] = sh.xcrun("-find", "-sdk", "iphoneos", "clang").splitlines()[0] - build_env["AR"] = sh.xcrun("-find", "-sdk", "iphoneos", "ar").splitlines()[0] - build_env["LD"] = sh.xcrun("-find", "-sdk", "iphoneos", "ld").splitlines()[0] + build_env["CC"] = sh.xcrun("-find", "-sdk", arch.sdk, "clang").strip() + build_env["AR"] = sh.xcrun("-find", "-sdk", arch.sdk, "ar").strip() + build_env["LD"] = sh.xcrun("-find", "-sdk", arch.sdk, "ld").strip() build_env["CFLAGS"] = " ".join([ - "-arch", arch, + "-arch", arch.arch, "-pipe", "-no-cpp-precomp", - "-isysroot", self.ctx.iossdkroot, + "-isysroot", arch.sysroot, "-O3", - "-miphoneos-version-min={}".format(self.ctx.sdkver)]) + "-miphoneos-version-min={}".format(arch.version_min)]) build_env["LDFLAGS"] = " ".join([ - "-arch", arch, + "-arch", arch.arch, "-undefined dynamic_lookup", "-Lextralibs/", "-lsqlite3", - "-isysroot", self.ctx.iossdkroot]) + "-isysroot", arch.sysroot]) configure = sh.Command(join(self.build_dir, "configure")) shprint(configure, diff --git a/recipes/python/__init__.pyc b/recipes/python/__init__.pyc index 2834000f9c62bb4ab5781539ce99155dc2c1deb3..ed3470c7b15e8d3f1007cdaa5450c53d8eac5cf3 100644 GIT binary patch delta 1303 zcm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