diff --git a/.github/workflows/kivy_ios.yml b/.github/workflows/kivy_ios.yml index e879721..b91399b 100644 --- a/.github/workflows/kivy_ios.yml +++ b/.github/workflows/kivy_ios.yml @@ -34,7 +34,7 @@ jobs: pip3 install sh brew install autoconf automake libtool pkg-config brew link libtool - pip3 install Cython==0.29.10 + pip3 install Cython==0.28.1 - name: Build updated recipes run: | python3 .ci/rebuild_updated_recipes.py diff --git a/recipes/host_setuptools3/__init__.py b/recipes/host_setuptools3/__init__.py index 4825f34..c7c1764 100644 --- a/recipes/host_setuptools3/__init__.py +++ b/recipes/host_setuptools3/__init__.py @@ -20,7 +20,7 @@ class HostSetuptools3(Recipe): # Setuptools version 28.3.0 site_packages_path = join( self.ctx.dist_dir, 'hostpython3', - 'lib', 'python3.7', 'site-packages') + 'lib', 'python3.8', 'site-packages') os.chdir(site_packages_path) with open('setuptools.pth', 'r') as f: setuptools_egg_path = f.read().strip('./').strip('\n') diff --git a/recipes/hostopenssl/__init__.py b/recipes/hostopenssl/__init__.py new file mode 100644 index 0000000..113dded --- /dev/null +++ b/recipes/hostopenssl/__init__.py @@ -0,0 +1,39 @@ +from toolchain import Recipe, shprint +from os.path import join +import sh +import logging + +logger = logging.getLogger(__name__) + + +class HostOpensslRecipe(Recipe): + version = "1.1.1f" + url = "http://www.openssl.org/source/openssl-{version}.tar.gz" + archs = ["x86_64"] + + def get_build_env(self): + build_env = self.ctx.env.copy() + self.build_env_x86_84 = build_env + return build_env + + def build_x86_64(self): + build_env = self.get_build_env() + configure = sh.Command(join(self.build_dir, "Configure")) + shprint(configure, + "darwin64-x86_64-cc", + _env=build_env) + shprint(sh.make, "clean") + shprint(sh.make, self.ctx.concurrent_make, "build_libs") + + def install(self): + sh.mkdir('-p', join(self.ctx.dist_dir, 'hostopenssl')) + sh.cp('-r', join(self.get_build_dir('x86_64'), 'include'), + join(self.ctx.dist_dir, 'hostopenssl', 'include')) + sh.mkdir('-p', join(self.ctx.dist_dir, 'hostopenssl', 'lib')) + sh.cp(join(self.get_build_dir('x86_64'), 'libssl.a'), + join(self.ctx.dist_dir, 'hostopenssl', 'lib')) + sh.cp(join(self.get_build_dir('x86_64'), 'libcrypto.a'), + join(self.ctx.dist_dir, 'hostopenssl', 'lib')) + + +recipe = HostOpensslRecipe() diff --git a/recipes/hostpython3/__init__.py b/recipes/hostpython3/__init__.py index c47bb79..d11c6a4 100644 --- a/recipes/hostpython3/__init__.py +++ b/recipes/hostpython3/__init__.py @@ -1,5 +1,5 @@ -from toolchain import Recipe, shprint, ensure_dir -from os.path import join, exists +from toolchain import Recipe, shprint +from os.path import join import os import sh import shutil @@ -9,16 +9,16 @@ logger = logging.getLogger(__name__) class Hostpython3Recipe(Recipe): - version = "3.7.1" + version = "3.8.2" url = "https://www.python.org/ftp/python/{version}/Python-{version}.tgz" - depends = [] - optional_depends = ["openssl"] + depends = ["hostlibffi", "hostopenssl"] + optional_depends = [] archs = ["x86_64"] def init_with_ctx(self, ctx): super(Hostpython3Recipe, self).init_with_ctx(ctx) - self.set_hostpython(self, "3.7") - self.ctx.so_suffix = ".cpython-37m-darwin.so" + self.set_hostpython(self, "3.8") + self.ctx.so_suffix = ".cpython-38m-darwin.so" self.ctx.hostpython = join(self.ctx.dist_dir, "hostpython3", "bin", "python") self.ctx.hostpgen = join(self.ctx.dist_dir, "hostpython3", "bin", "pgen") logger.info("Global: hostpython located at {}".format(self.ctx.hostpython)) @@ -28,33 +28,10 @@ class Hostpython3Recipe(Recipe): if self.has_marker("patched"): return self.copy_file("ModulesSetup", "Modules/Setup.local") - # self.apply_patch("ssize-t-max.patch") - # self.apply_patch("dynload.patch") - # self.apply_patch("static-_sqlite3.patch") - # shutil.copy("Modules/Setup.dist", "Modules/Setup") - # if "openssl.build_all" in self.ctx.state: - # self.append_file("ModulesSetup.openssl", "Modules/Setup.local") self.set_marker("patched") def postbuild_arch(self, arch): return - """ - makefile_fn = join(self.build_dir, "Makefile") - with open(makefile_fn) as fd: - lines = fd.readlines() - for index, line in enumerate(lines): - if "-bundle" not in line: - continue - parts = line.split(" ") - parts.remove("-bundle") - if "-bundle_loader" in parts: - i = parts.index("-bundle_loader") - parts.pop(i) - parts.pop(i) - lines[index] = " ".join(parts) - with open(makefile_fn, "w") as fd: - fd.writelines(lines) - """ def get_build_env(self): sdk_path = sh.xcrun("--sdk", "macosx", "--show-sdk-path").strip() @@ -73,10 +50,6 @@ class Hostpython3Recipe(Recipe): "-mmacosx-version-min=10.12", "-I{}".format(join(self.ctx.dist_dir, "hostlibffi", "usr", "local", "include")) ]) - if "openssl.build_all" in self.ctx.state: - build_env["LDFLAGS"] += " -L{}".format(join(self.ctx.dist_dir, "lib")) - build_env["CFLAGS"] += " -I{}".format(join(self.ctx.dist_dir, "include", - "x86_64", "openssl")) return build_env def build_x86_64(self): @@ -84,41 +57,33 @@ class Hostpython3Recipe(Recipe): configure = sh.Command(join(self.build_dir, "configure")) shprint(configure, "--prefix={}".format(join(self.ctx.dist_dir, "hostpython3")), - # "--disable-toolbox-glue", - # "--without-gcc", + "--with-openssl={}".format(join(self.ctx.dist_dir, 'hostopenssl')), _env=build_env) shprint(sh.make, "-C", self.build_dir, self.ctx.concurrent_make, _env=build_env) - # shutil.move("python", "hostpython") - # shutil.move("Parser/pgen", "Parser/hostpgen") def install(self): arch = list(self.filtered_archs)[0] build_env = self.get_build_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, "hostpython3"), - # join(build_dir, "Python")) shprint(sh.make, self.ctx.concurrent_make, "-C", build_dir, "install", _env=build_env) - # pylib_dir = join(self.ctx.dist_dir, "hostpython3", "lib", "python3.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(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) recipe = Hostpython3Recipe() diff --git a/recipes/kivy/__init__.py b/recipes/kivy/__init__.py index 3f95553..50b4909 100644 --- a/recipes/kivy/__init__.py +++ b/recipes/kivy/__init__.py @@ -9,8 +9,13 @@ logger = logging.getLogger(__name__) class KivyRecipe(CythonRecipe): - # post kivy 1.11.1, including statusbar/fullscreen fix - version = "38fcbd5b90c99a96d82682f14986836cde81412d" + """ + post kivy 2.0.0rc1 + Includes these iOS specific fixes: + - Statusbar / Fullscreen fix (PR #4589) + - Extend usage of certifi on iOS (PR #4648) + """ + version = "067064c23a275187e67f1c9d7de7cc06f384af4d" url = "https://github.com/kivy/kivy/archive/{version}.zip" library = "libkivy.a" depends = ["sdl2", "sdl2_image", "sdl2_mixer", "sdl2_ttf", "ios", diff --git a/recipes/python3/ModulesSetup b/recipes/python3/ModulesSetup index f35d5f6..9a1bfcf 100644 --- a/recipes/python3/ModulesSetup +++ b/recipes/python3/ModulesSetup @@ -68,7 +68,7 @@ zlib zlibmodule.c -I$(prefix)/include -lz ##################################################################### _ctypes_test _ctypes/_ctypes_test.c _testbuffer _testbuffer.c -_testcapi _testcapimodule.c +_testinternalcapi _testinternalcapi.c _testimportmultiple _testimportmultiple.c ##################################################################### diff --git a/recipes/python3/__init__.py b/recipes/python3/__init__.py index fcfc906..f8829be 100644 --- a/recipes/python3/__init__.py +++ b/recipes/python3/__init__.py @@ -9,30 +9,33 @@ logger = logging.getLogger(__name__) class Python3Recipe(Recipe): - version = "3.7.1" + version = "3.8.2" url = "https://www.python.org/ftp/python/{version}/Python-{version}.tgz" depends = ["hostpython3", "libffi", "openssl"] - library = "libpython3.7m.a" + library = "libpython3.8.a" pbx_libraries = ["libz", "libbz2", "libsqlite3"] def init_with_ctx(self, ctx): super(Python3Recipe, self).init_with_ctx(ctx) - self.set_python(self, "3.7") - ctx.python_ver_dir = "python3.7" + self.set_python(self, "3.8") + ctx.python_ver_dir = "python3.8" ctx.python_prefix = join(ctx.dist_dir, "root", "python3") ctx.site_packages_dir = join( ctx.python_prefix, "lib", ctx.python_ver_dir, "site-packages") def prebuild_arch(self, arch): # common to all archs - if self.has_marker("patched"): + if self.has_marker("patched"): return - self.apply_patch("dynload.patch") + self.apply_patch("config.sub.patch") + self.apply_patch("configure.patch") + self.apply_patch("posixmodule.patch") + self.apply_patch("dynload_shlib.patch") + self.apply_patch("disable_explicit_blake2.patch") self.copy_file("ModulesSetup", "Modules/Setup.local") self.append_file("ModulesSetup.mobile", "Modules/Setup.local") - self.apply_patch("xcompile.patch") self.set_marker("patched") - + def postbuild_arch(self, arch): # include _sqlite module to .a py_arch = arch.arch @@ -40,7 +43,7 @@ class Python3Recipe(Recipe): py_arch = "arm" elif py_arch == "arm64": py_arch = "aarch64" - tmp_folder = "temp.ios-{}-3.7{}".format(py_arch, self.build_dir) + tmp_folder = "temp.ios-{}-3.8{}".format(py_arch, self.build_dir) build_env = self.get_build_env(arch) for o_file in [ "cache.o", @@ -81,7 +84,6 @@ class Python3Recipe(Recipe): "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", @@ -114,10 +116,13 @@ class Python3Recipe(Recipe): "--prefix={}".format(prefix), "--without-ensurepip", "--with-system-ffi", - # "--without-doc-strings", "--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) @@ -130,7 +135,6 @@ class Python3Recipe(Recipe): "install", "prefix={}".format(join(self.ctx.dist_dir, "root", "python3")), _env=build_env) - # os.execve("/bin/bash", ["/bin/bash"], os.environ) self.reduce_python() self.install_mock_modules() @@ -138,24 +142,22 @@ class Python3Recipe(Recipe): logger.info("Install mock modules") sqlite3_src = join(self.recipe_dir, 'mock_modules', '_sqlite3') site_packages_folder = join( - self.ctx.dist_dir, "root", "python3", "lib", "python3.7", "site-packages", "_sqlite3") - shutil.rmtree(site_packages_folder, ignore_errors=True) # Needed in case of rebuild + self.ctx.dist_dir, "root", "python3", "lib", "python3.8", "site-packages", "_sqlite3") + shutil.rmtree(site_packages_folder, ignore_errors=True) # Needed in case of rebuild shutil.copytree(sqlite3_src, site_packages_folder) - + 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") + "python3.8", "config-3.8-darwin")) + sh.rm("libpython3.8.a") sh.rm("python.o") sh.rm("config.c.in") sh.rm("makesetup") @@ -164,11 +166,11 @@ class Python3Recipe(Recipe): # 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") + sh.rm("-f", "libpython3.8.a") # cleanup python libraries os.chdir(join( - self.ctx.dist_dir, "root", "python3", "lib", "python3.7")) + self.ctx.dist_dir, "root", "python3", "lib", "python3.8")) sh.rm("-rf", "wsgiref", "curses", "idlelib", "lib2to3", "ensurepip", "turtledemo", "lib-dynload", "venv", "pydoc_data") @@ -189,12 +191,12 @@ class Python3Recipe(Recipe): sh.find(".", "-name", "__pycache__", "-type", "d", "-delete") # create the lib zip - logger.info("Create a python3.7.zip") - sh.mv("config-3.7m-darwin", "..") + logger.info("Create a python3.8.zip") + sh.mv("config-3.8-darwin", "..") sh.mv("site-packages", "..") - sh.zip("-r", "../python37.zip", sh.glob("*")) + sh.zip("-r", "../python38.zip", sh.glob("*")) sh.rm("-rf", sh.glob("*")) - sh.mv("../config-3.7m-darwin", ".") + sh.mv("../config-3.8-darwin", ".") sh.mv("../site-packages", ".") finally: os.chdir(oldpwd) diff --git a/recipes/python3/config.sub.patch b/recipes/python3/config.sub.patch new file mode 100644 index 0000000..3864034 --- /dev/null +++ b/recipes/python3/config.sub.patch @@ -0,0 +1,31 @@ +diff -Naur Python-3.8.2.orig/.building Python-3.8.2/.building +--- Python-3.8.2.orig/.building 2020-04-11 23:53:30.000000000 +0200 ++++ Python-3.8.2/.building 1970-01-01 01:00:00.000000000 +0100 +@@ -1 +0,0 @@ +-ok +\ No newline at end of file +diff -Naur Python-3.8.2.orig/config.sub Python-3.8.2/config.sub +--- Python-3.8.2.orig/config.sub 2020-04-11 23:53:40.000000000 +0200 ++++ Python-3.8.2/config.sub 2020-04-11 23:51:41.000000000 +0200 +@@ -249,7 +249,7 @@ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ + | am33_2.0 \ + | arc | arceb \ +- | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv6m | armv[78][arm] \ ++ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv6m | armv[78][armk] \ + | avr | avr32 \ + | ba \ + | be32 | be64 \ +@@ -1524,7 +1524,11 @@ + ;; + -nacl*) + ;; +- -ios) ++ -ios*) ++ ;; ++ -tvos*) ++ ;; ++ -watchos*) + ;; + -none) + ;; diff --git a/recipes/python3/configure.patch b/recipes/python3/configure.patch new file mode 100644 index 0000000..e551764 --- /dev/null +++ b/recipes/python3/configure.patch @@ -0,0 +1,90 @@ +diff -Naur Python-3.8.2.orig/configure Python-3.8.2/configure +--- Python-3.8.2.orig/configure 2020-04-12 00:00:42.000000000 +0200 ++++ Python-3.8.2/configure 2020-04-12 00:08:45.000000000 +0200 +@@ -3271,6 +3271,15 @@ + *-*-cygwin*) + ac_sys_system=Cygwin + ;; ++ *-apple-ios) ++ ac_sys_system=iOS ++ ;; ++ *-apple-tvos) ++ ac_sys_system=tvOS ++ ;; ++ *-apple-watchos) ++ ac_sys_system=watchOS ++ ;; + *-*-vxworks*) + ac_sys_system=VxWorks + ;; +@@ -3318,6 +3327,15 @@ + _host_cpu=$host_cpu + esac + ;; ++ *-apple-*) ++ case "$host_cpu" in ++ arm*) ++ _host_cpu=arm ++ ;; ++ *) ++ _host_cpu=$host_cpu ++ esac ++ ;; + *-*-cygwin*) + _host_cpu= + ;; +@@ -3396,6 +3414,13 @@ + define_xopen_source=no;; + Darwin/1[0-9].*) + define_xopen_source=no;; ++ # On iOS, defining _POSIX_C_SOURCE also disables platform specific features. ++ iOS/*) ++ define_xopen_source=no;; ++ tvOS/*) ++ define_xopen_source=no;; ++ watchOS/*) ++ define_xopen_source=no;; + # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but + # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined + # or has another value. By not (re)defining it, the defaults come in place. +@@ -6165,10 +6190,16 @@ + fi + + if test "$cross_compiling" = yes; then +- case "$READELF" in +- readelf|:) +- as_fn_error $? "readelf for the host is required for cross builds" "$LINENO" 5 +- ;; ++ case "$host" in ++ *-apple-*os) ++ # readelf not required for iOS cross builds. ++ ;; ++ *) ++ case "$READELF" in ++ readelf|:) ++ as_fn_error $? "readelf for the host is required for cross builds" "$LINENO" 5 ++ ;; ++ esac + esac + fi + +@@ -6920,8 +6951,6 @@ + # tweak BASECFLAGS based on compiler and platform + case $GCC in + yes) +- CFLAGS_NODIST="$CFLAGS_NODIST -std=c99" +- + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -Wextra" >&5 + $as_echo_n "checking for -Wextra... " >&6; } + ac_save_cc="$CC" +@@ -11438,6 +11467,10 @@ + ;; + hp*|HP*) DYNLOADFILE="dynload_hpux.o";; ++ # Dynamic loading on iOS ++ iOS/*) DYNLOADFILE="dynload_shlib.o";; ++ tvOS/*) DYNLOADFILE="dynload_shlib.o";; ++ watchOS/*) DYNLOADFILE="dynload_shlib.o";; + *) + # use dynload_shlib.c and dlopen() if we have it; otherwise stub + # out any dynamic loading + if test "$ac_cv_func_dlopen" = yes diff --git a/recipes/python3/ctypes_duplicate.patch b/recipes/python3/ctypes_duplicate.patch index b2231e9..ecb0a37 100644 --- a/recipes/python3/ctypes_duplicate.patch +++ b/recipes/python3/ctypes_duplicate.patch @@ -1,17 +1,19 @@ ---- Python-3.7.1/Modules/_ctypes/cfield.c-old 2018-11-03 13:47:40.000000000 +0100 -+++ Python-3.7.1/Modules/_ctypes/cfield.c 2018-11-03 13:48:14.000000000 +0100 -@@ -1633,6 +1633,7 @@ +diff -Naur Python-3.8.2.orig/Modules/_ctypes/cfield.c Python-3.8.2/Modules/_ctypes/cfield.c +--- Python-3.8.2.orig/Modules/_ctypes/cfield.c 2020-04-13 12:23:46.000000000 +0200 ++++ Python-3.8.2/Modules/_ctypes/cfield.c 2020-04-13 12:24:45.000000000 +0200 +@@ -1636,7 +1636,7 @@ + struct _ffi_type **elements; } ffi_type; */ - +- +#if 0 /* align and size are bogus for void, but they must not be zero */ ffi_type ffi_type_void = { 1, 1, FFI_TYPE_VOID }; -@@ -1660,4 +1661,6 @@ +@@ -1663,5 +1663,5 @@ + FFI_TYPE_LONGDOUBLE }; ffi_type ffi_type_pointer = { sizeof(void *), VOID_P_ALIGN, FFI_TYPE_POINTER }; - +- +#endif -+ /*---------------- EOF ----------------*/ diff --git a/recipes/python3/disable_explicit_blake2.patch b/recipes/python3/disable_explicit_blake2.patch new file mode 100644 index 0000000..1b0210b --- /dev/null +++ b/recipes/python3/disable_explicit_blake2.patch @@ -0,0 +1,12 @@ +diff -Naur Python-3.8.2.orig/Modules/_blake2/impl/blake2-impl.h Python-3.8.2/Modules/_blake2/impl/blake2-impl.h +--- Python-3.8.2.orig/Modules/_blake2/impl/blake2-impl.h 2020-04-12 01:20:03.000000000 +0200 ++++ Python-3.8.2/Modules/_blake2/impl/blake2-impl.h 2020-04-12 01:21:11.000000000 +0200 +@@ -26,6 +26,8 @@ + #define BLAKE2_IMPL_EVAL(x,y) BLAKE2_IMPL_CAT(x,y) + #define BLAKE2_IMPL_NAME(fun) BLAKE2_IMPL_EVAL(fun, SUFFIX) + ++#undef HAVE_EXPLICIT_BZERO ++#undef HAVE_EXPLICIT_MEMSET + static inline uint32_t load32( const void *src ) + { + #if defined(NATIVE_LITTLE_ENDIAN) diff --git a/recipes/python3/dynload.patch b/recipes/python3/dynload_shlib.patch similarity index 68% rename from recipes/python3/dynload.patch rename to recipes/python3/dynload_shlib.patch index a5e080f..8393219 100644 --- a/recipes/python3/dynload.patch +++ b/recipes/python3/dynload_shlib.patch @@ -1,9 +1,10 @@ ---- Python-3.7.1/Python/dynload_shlib.c 2018-10-20 08:04:19.000000000 +0200 -+++ Python-3.7.1/Python/dynload_shlib.c 2018-11-02 14:23:15.000000000 +0100 -@@ -72,6 +72,16 @@ +diff -Naur Python-3.8.2.orig/Python/dynload_shlib.c Python-3.8.2/Python/dynload_shlib.c +--- Python-3.8.2.orig/Python/dynload_shlib.c 2020-04-12 00:17:24.000000000 +0200 ++++ Python-3.8.2/Python/dynload_shlib.c 2020-04-12 00:20:10.000000000 +0200 +@@ -74,6 +74,15 @@ + PyOS_snprintf(funcname, sizeof(funcname), LEAD_UNDERSCORE "%.20s_%.200s", prefix, 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 @@ -12,14 +13,13 @@ + */ + return (dl_funcptr) dlsym(RTLD_SELF, funcname); + -+#if 0 -+ ++ #if 0 + if (fp != NULL) { int i; - struct _Py_stat_struct status; -@@ -126,4 +136,5 @@ +@@ -129,4 +138,5 @@ handles[nhandles++].handle = handle; p = (dl_funcptr) dlsym(handle, funcname); return p; -+#endif ++ #endif } diff --git a/recipes/python3/mock_modules/_sqlite3/_sqlite3.cpython-37m-darwin.so b/recipes/python3/mock_modules/_sqlite3/_sqlite3.cpython-38-darwin.so similarity index 100% rename from recipes/python3/mock_modules/_sqlite3/_sqlite3.cpython-37m-darwin.so rename to recipes/python3/mock_modules/_sqlite3/_sqlite3.cpython-38-darwin.so diff --git a/recipes/python3/mock_modules/_sqlite3/_sqlite3.py b/recipes/python3/mock_modules/_sqlite3/_sqlite3.py deleted file mode 100644 index f6dc2f9..0000000 --- a/recipes/python3/mock_modules/_sqlite3/_sqlite3.py +++ /dev/null @@ -1,10 +0,0 @@ -""" -def __bootstrap__(): - global __bootstrap__, __loader__, __file__ - import sys, pkg_resources, imp - __file__ = pkg_resources.resource_filename(__name__, '_sqlite3.cpython-37m-darwin.so') - __loader__ = None; del __bootstrap__, __loader__ - print("demo") - imp.load_dynamic(__name__,__file__) -__bootstrap__() -""" diff --git a/recipes/python3/posixmodule.patch b/recipes/python3/posixmodule.patch new file mode 100644 index 0000000..1669608 --- /dev/null +++ b/recipes/python3/posixmodule.patch @@ -0,0 +1,31 @@ +diff -Naur Python-3.8.2.orig/Modules/posixmodule.c Python-3.8.2/Modules/posixmodule.c +--- Python-3.8.2.orig/Modules/posixmodule.c 2020-04-12 00:11:47.000000000 +0200 ++++ Python-3.8.2/Modules/posixmodule.c 2020-04-12 00:13:21.000000000 +0200 +@@ -216,6 +216,27 @@ + #endif /* _MSC_VER */ + #endif /* ! __WATCOMC__ || __QNX__ */ + ++// iOS ++#undef HAVE_EXECV ++#undef HAVE_FORK ++#undef HAVE_FORK1 ++#undef HAVE_FORKPTY ++#undef HAVE_GETGROUPS ++#undef HAVE_SCHED_H ++#undef HAVE_SENDFILE ++#undef HAVE_SETPRIORITY ++#undef HAVE_SPAWNV ++#undef HAVE_WAIT ++#undef HAVE_WAIT3 ++#undef HAVE_WAIT4 ++#undef HAVE_WAITPID ++#undef HAVE_SYSTEM ++#undef HAVE_FEXECVE ++#undef HAVE_RTPSPAWN ++#undef HAVE_POSIX_SPAWN ++#undef HAVE_POSIX_SPAWNP ++#undef HAVE_FDWALK ++#undef HAVE_COPY_FILE_RANGE + + /*[clinic input] + # one of the few times we lie about this name! diff --git a/recipes/python3/xcompile.patch b/recipes/python3/xcompile.patch deleted file mode 100644 index f5e0e9f..0000000 --- a/recipes/python3/xcompile.patch +++ /dev/null @@ -1,145 +0,0 @@ ---- Python-3.7.1.orig/config.sub 2018-10-20 08:04:19.000000000 +0200 -+++ Python-3.7.1/config.sub 2018-10-31 13:31:22.000000000 +0100 -@@ -249,7 +249,7 @@ - | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \ - | am33_2.0 \ - | arc | arceb \ -- | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv6m | armv[78][arm] \ -+ | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv6m | armv[78][armk] \ - | avr | avr32 \ - | ba \ - | be32 | be64 \ -@@ -1524,7 +1524,11 @@ - ;; - -nacl*) - ;; -- -ios) -+ -ios*) -+ ;; -+ -tvos*) -+ ;; -+ -watchos*) - ;; - -none) - ;; ---- Python-3.7.1.orig/configure 2018-10-20 08:04:19.000000000 +0200 -+++ Python-3.7.1/configure 2018-10-31 13:41:38.000000000 +0100 -@@ -3253,6 +3253,15 @@ - *-*-cygwin*) - ac_sys_system=Cygwin - ;; -+ *-apple-ios) -+ ac_sys_system=iOS -+ ;; -+ *-apple-tvos) -+ ac_sys_system=tvOS -+ ;; -+ *-apple-watchos) -+ ac_sys_system=watchOS -+ ;; - *) - # for now, limit cross builds to known configurations - MACHDEP="unknown" -@@ -3294,6 +3303,15 @@ - _host_cpu=$host_cpu - esac - ;; -+ *-apple-*) -+ case "$host_cpu" in -+ arm*) -+ _host_cpu=arm -+ ;; -+ *) -+ _host_cpu=$host_cpu -+ esac -+ ;; - *-*-cygwin*) - _host_cpu= - ;; -@@ -3369,6 +3387,13 @@ - define_xopen_source=no;; - Darwin/1[0-9].*) - define_xopen_source=no;; -+ # On iOS, defining _POSIX_C_SOURCE also disables platform specific features. -+ iOS/*) -+ define_xopen_source=no;; -+ tvOS/*) -+ define_xopen_source=no;; -+ watchOS/*) -+ define_xopen_source=no;; - # On AIX 4 and 5.1, mbstate_t is defined only when _XOPEN_SOURCE == 500 but - # used in wcsnrtombs() and mbsnrtowcs() even if _XOPEN_SOURCE is not defined - # or has another value. By not (re)defining it, the defaults come in place. -@@ -6176,11 +6201,17 @@ - fi - - if test "$cross_compiling" = yes; then -- case "$READELF" in -- readelf|:) -- as_fn_error $? "readelf for the host is required for cross builds" "$LINENO" 5 -- ;; -- esac -+ case "$host" in -+ *-apple-*os) -+ # readelf not required for iOS cross builds. -+ ;; -+ *) -+ case "$READELF" in -+ readelf|:) -+ as_fn_error $? "readelf for the host is required for cross builds" "$LINENO" 5 -+ ;; -+ esac -+ esac - fi - - -@@ -6803,8 +6834,6 @@ - # tweak BASECFLAGS based on compiler and platform - case $GCC in - yes) -- CFLAGS_NODIST="$CFLAGS_NODIST -std=c99" -- - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -Wextra" >&5 - $as_echo_n "checking for -Wextra... " >&6; } - ac_save_cc="$CC" -@@ -11281,6 +11310,10 @@ - fi - ;; - hp*|HP*) DYNLOADFILE="dynload_hpux.o";; -+ # Dynamic loading on iOS -+ iOS/*) DYNLOADFILE="dynload_shlib.o";; -+ tvOS/*) DYNLOADFILE="dynload_shlib.o";; -+ watchOS/*) DYNLOADFILE="dynload_shlib.o";; - *) - # use dynload_shlib.c and dlopen() if we have it; otherwise stub - # out any dynamic loading -@@ -18383,4 +18416,3 @@ - echo "" >&6 - echo "" >&6 - fi -- ---- Python-3.7.1.orig/Modules/posixmodule.c 2018-10-20 08:04:19.000000000 +0200 -+++ Python-3.7.1/Modules/posixmodule.c 2018-10-31 15:00:14.000000000 +0100 -@@ -194,6 +194,22 @@ - #endif /* _MSC_VER */ - #endif /* ! __WATCOMC__ || __QNX__ */ - -+// iOS -+#undef HAVE_EXECV -+#undef HAVE_FORK -+#undef HAVE_FORK1 -+#undef HAVE_FORKPTY -+#undef HAVE_GETGROUPS -+#undef HAVE_SCHED_H -+#undef HAVE_SENDFILE -+#undef HAVE_SETPRIORITY -+#undef HAVE_SPAWNV -+#undef HAVE_WAIT -+#undef HAVE_WAIT3 -+#undef HAVE_WAIT4 -+#undef HAVE_WAITPID -+#undef HAVE_SYSTEM -+#undef HAVE_FEXECVE - - /*[clinic input] - # one of the few times we lie about this name! diff --git a/toolchain.py b/toolchain.py index 62c8e29..dcbcdd4 100755 --- a/toolchain.py +++ b/toolchain.py @@ -1093,6 +1093,7 @@ class CythonRecipe(PythonRecipe): env = super(CythonRecipe, self).get_recipe_env(arch) env["KIVYIOSROOT"] = self.ctx.root_dir env["IOSSDKROOT"] = arch.sysroot + env["CUSTOMIZED_OSX_COMPILER"] = 'True' env["LDSHARED"] = join(self.ctx.root_dir, "tools", "liblink") env["ARM_LD"] = env["LD"] env["ARCH"] = arch.arch @@ -1475,9 +1476,9 @@ Xcode: print("env ({}): {}".format(arch, pformat(env))) def pip3(self): - self.pip(pip_version="pip3") + self.pip() - def pip(self, pip_version="pip"): + def pip(self): ctx = Context() for recipe in Recipe.list_recipes(): key = "{}.build_all".format(recipe) @@ -1496,7 +1497,7 @@ Xcode: "PYTHONOPTIMIZE": "2", # "PIP_INSTALL_TARGET": ctx.site_packages_dir } - pip_path = sh.which(pip_version) + pip_path = join(ctx.dist_dir, 'hostpython3', 'bin', 'pip3') pip_args = [] if len(sys.argv) > 2 and sys.argv[2] == "install": pip_args = ["--isolated", "--ignore-installed", "--prefix", ctx.python_prefix] @@ -1504,9 +1505,6 @@ Xcode: else: args = [pip_path] + pip_args + sys.argv[2:] - if not pip_path: - logger.error("pip not found") - sys.exit(1) import os logger.error("Executing pip with: {}".format(args)) os.execve(pip_path, args, pip_env) diff --git a/tools/templates/{{ cookiecutter.project_name }}-ios/main.m b/tools/templates/{{ cookiecutter.project_name }}-ios/main.m index 6a09ed4..0c032a4 100644 --- a/tools/templates/{{ cookiecutter.project_name }}-ios/main.m +++ b/tools/templates/{{ cookiecutter.project_name }}-ios/main.m @@ -5,11 +5,7 @@ #import #import -{%- if cookiecutter.python_major == "2" %} -#include "{{ cookiecutter.kivy_dir }}/dist/root/python2/include/python2.7/Python.h" -{%- else %} -#include "{{ cookiecutter.kivy_dir }}/dist/root/python3/include/python3.7m/Python.h" -{%- endif %} +#include "Python.h" #include "{{ cookiecutter.kivy_dir }}/dist/include/common/sdl2/SDL_main.h" #include @@ -31,6 +27,7 @@ int main(int argc, char *argv[]) { putenv("PYTHONNOUSERSITE=1"); putenv("PYTHONPATH=."); putenv("PYTHONUNBUFFERED=1"); + putenv("LC_CTYPE=UTF-8"); // putenv("PYTHONVERBOSE=1"); // putenv("PYOBJUS_DEBUG=1"); @@ -61,7 +58,7 @@ int main(int argc, char *argv[]) { NSString *python_home = [NSString stringWithFormat:@"PYTHONHOME=%@", resourcePath, nil]; putenv((char *)[python_home UTF8String]); - NSString *python_path = [NSString stringWithFormat:@"PYTHONPATH=%@:%@/lib/python3.7/:%@/lib/python3.7/site-packages:.", resourcePath, resourcePath, resourcePath, nil]; + NSString *python_path = [NSString stringWithFormat:@"PYTHONPATH=%@:%@/lib/python3.8/:%@/lib/python3.8/site-packages:.", resourcePath, resourcePath, resourcePath, nil]; putenv((char *)[python_path UTF8String]); NSString *tmp_path = [NSString stringWithFormat:@"TMP=%@/tmp", resourcePath, nil]; @@ -163,6 +160,8 @@ void load_custom_builtin_importer() { " sys.modules['subprocess'].PIPE = None\n" \ " sys.modules['subprocess'].STDOUT = None\n" \ " sys.modules['subprocess'].DEVNULL = None\n" \ + " sys.modules['subprocess'].CalledProcessError = Exception\n" \ + " sys.modules['subprocess'].check_output = None\n" \ "except ImportError:\n" \ " EXTS = ['.so']\n" "# Fake redirection to supress console output\n" \ diff --git a/tools/templates/{{ cookiecutter.project_name }}-ios/{{ cookiecutter.project_name }}.xcodeproj/project.pbxproj b/tools/templates/{{ cookiecutter.project_name }}-ios/{{ cookiecutter.project_name }}.xcodeproj/project.pbxproj index db84658..85adc25 100755 --- a/tools/templates/{{ cookiecutter.project_name }}-ios/{{ cookiecutter.project_name }}.xcodeproj/project.pbxproj +++ b/tools/templates/{{ cookiecutter.project_name }}-ios/{{ cookiecutter.project_name }}.xcodeproj/project.pbxproj @@ -291,7 +291,7 @@ GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1"; GCC_VERSION = com.apple.compilers.llvm.clang.1_0; HEADER_SEARCH_PATHS = ( - "{{ cookiecutter.dist_dir }}/root/python/include", + "{{ cookiecutter.dist_dir }}/root/python3/include/python3.8/**", "{{ cookiecutter.dist_dir }}/include/common/sdl2", ); INFOPLIST_FILE = "{{ cookiecutter.project_name }}-Info.plist"; diff --git a/tox.ini b/tox.ini index 86d7ba9..142527c 100644 --- a/tox.ini +++ b/tox.ini @@ -12,6 +12,7 @@ setenv = deps = flake8 commands = flake8 recipes/ tools/ tests/ .ci/ toolchain.py + [flake8] exclude = tools/external/, toolchain.py, # Temporary removal: TODO: ZenCODE @@ -28,4 +29,4 @@ ignore = E402, # Module level import not at top of file E501, # Line too long (82 > 79 characters) W503, # Line break occurred before a binary operator - W504 # Line break occurred after a binary operator + W504 # Line break occurred after a binary operator \ No newline at end of file