Skip to content

Commit

Permalink
Update Python3 recipe to 3.11.6
Browse files Browse the repository at this point in the history
  • Loading branch information
misl6 committed Oct 17, 2023
1 parent 4e21ff2 commit 126d1c7
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 78 deletions.
10 changes: 5 additions & 5 deletions kivy_ios/recipes/hostpython3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@


class Hostpython3Recipe(HostRecipe):
version = "3.10.10"
version = "3.11.6"
url = "https://www.python.org/ftp/python/{version}/Python-{version}.tgz"
depends = ["hostopenssl"]
optional_depends = []
build_subdir = 'native-build'

def init_with_ctx(self, ctx):
super().init_with_ctx(ctx)
self.set_hostpython(self, "3.10")
self.ctx.so_suffix = ".cpython-310m-darwin.so"
self.set_hostpython(self, "3.11")
self.ctx.so_suffix = ".cpython-311m-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))
Expand Down Expand Up @@ -88,7 +88,7 @@ def install(self):
join(self.ctx.dist_dir, "hostpython3", "bin", "python"))

# hostpython3 installs bundled versions of `pip`
# and `setuptools` in `lib/python3.10/site-packages`.
# and `setuptools` in `lib/python3.x/site-packages`.
# This is fine, but `setuptools` have a bug that prevents
# it from working properly when cross-compiling, so we
# patch it here.
Expand All @@ -100,7 +100,7 @@ def install(self):
self.ctx.dist_dir,
"hostpython3",
"lib",
"python3.10",
"python3.11",
"site-packages",
"setuptools",
),
Expand Down
20 changes: 10 additions & 10 deletions kivy_ios/recipes/python3/ModulesSetup
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
_asyncio _asynciomodule.c
_bisect _bisectmodule.c
_blake2 _blake2/blake2module.c _blake2/blake2b_impl.c _blake2/blake2s_impl.c
_sqlite3 _sqlite/cache.c \
_sqlite/connection.c \
_sqlite/cursor.c \
_sqlite/microprotocols.c \
_sqlite/module.c \
_sqlite/prepare_protocol.c \
_sqlite/row.c \
_sqlite/statement.c \
_sqlite/util.c -DSQLITE_OMIT_LOAD_EXTENSION
_sqlite3 _sqlite/blob.c \
_sqlite/connection.c \
_sqlite/cursor.c \
_sqlite/microprotocols.c \
_sqlite/module.c \
_sqlite/prepare_protocol.c \
_sqlite/row.c \
_sqlite/statement.c \
_sqlite/util.c -DSQLITE_OMIT_LOAD_EXTENSION
_bz2 _bz2module.c -I$(srcdir)/../bzip2/include -L$(srcdir)/../Support/BZip2 -lbz2
_codecs_cn cjkcodecs/_codecs_cn.c
_codecs_hk cjkcodecs/_codecs_hk.c
Expand Down Expand Up @@ -52,9 +52,9 @@ _struct _struct.c
array arraymodule.c
audioop audioop.c
binascii binascii.c
cmath cmathmodule.c _math.c
fcntl fcntlmodule.c
grp grpmodule.c
cmath cmathmodule.c
math mathmodule.c
mmap mmapmodule.c
pyexpat expat/xmlparse.c \
Expand Down
31 changes: 17 additions & 14 deletions kivy_ios/recipes/python3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@


class Python3Recipe(Recipe):
version = "3.10.10"
version = "3.11.6"
url = "https://www.python.org/ftp/python/{version}/Python-{version}.tgz"
depends = ["hostpython3", "libffi", "openssl"]
library = "libpython3.10.a"
library = "libpython3.11.a"
pbx_libraries = ["libz", "libbz2", "libsqlite3"]

def init_with_ctx(self, ctx):
super().init_with_ctx(ctx)
self.set_python(self, "3.10")
ctx.python_ver_dir = "python3.10"
self.set_python(self, "3.11")
ctx.python_ver_dir = "python3.11"
ctx.python_prefix = join(ctx.dist_dir, "root", "python3")
ctx.site_packages_dir = join(
ctx.python_prefix, "lib", ctx.python_ver_dir, "site-packages")
Expand All @@ -28,9 +28,7 @@ def prebuild_platform(self, plat):
if self.has_marker("patched"):
return
self.apply_patch("configure.patch")
self.apply_patch("posixmodule.patch")
self.apply_patch("dynload_shlib.patch")
self.apply_patch("ctypes_duplicate.patch")
self.copy_file("ModulesSetup", "Modules/Setup.local")
self.append_file("ModulesSetup.mobile", "Modules/Setup.local")
self.set_marker("patched")
Expand Down Expand Up @@ -97,10 +95,15 @@ def build_platform(self, plat):
"ac_cv_func_explicit_bzero=no",
"ac_cv_func_explicit_memset=no",
"ac_cv_func_close_range=no",
"ac_cv_search_crypt_r=no",
"ac_cv_func_fork1=no",
"ac_cv_func_system=no",
"ac_cv_func_clock_nanosleep=no",
"ac_cv_func_splice=no",
"ac_cv_func_mremap=no",
"--host={}-apple-ios".format(py_arch),
"--build=x86_64-apple-darwin",
"--with-build-python={}".format(join(self.ctx.dist_dir, "hostpython3", "bin", "python3")),
"--prefix={}".format(prefix),
"--without-ensurepip",
"--with-system-ffi",
Expand Down Expand Up @@ -132,9 +135,9 @@ def reduce_python(self):
# platform binaries and configuration
with cd(join(
self.ctx.dist_dir, "root", "python3", "lib",
"python3.10", "config-3.10-darwin")):
"python3.11", "config-3.11-darwin")):
sh.rm(
"libpython3.10.a",
"libpython3.11.a",
"python.o",
"config.c.in",
"makesetup",
Expand All @@ -143,11 +146,11 @@ def reduce_python(self):

# cleanup pkgconfig and compiled lib
with cd(join(self.ctx.dist_dir, "root", "python3", "lib")):
sh.rm("-rf", "pkgconfig", "libpython3.10.a")
sh.rm("-rf", "pkgconfig", "libpython3.11.a")

# cleanup python libraries
with cd(join(
self.ctx.dist_dir, "root", "python3", "lib", "python3.10")):
self.ctx.dist_dir, "root", "python3", "lib", "python3.11")):
sh.rm("-rf", "wsgiref", "curses", "idlelib", "lib2to3",
"ensurepip", "turtledemo", "lib-dynload", "venv",
"pydoc_data")
Expand All @@ -168,12 +171,12 @@ def reduce_python(self):
sh.find(".", "-name", "__pycache__", "-type", "d", "-delete")

# create the lib zip
logger.info("Create a python3.10.zip")
sh.mv("config-3.10-darwin", "..")
logger.info("Create a python3.11.zip")
sh.mv("config-3.11-darwin", "..")
sh.mv("site-packages", "..")
sh.zip("-r", "../python310.zip", sh.glob("*"))
sh.zip("-r", "../python311.zip", sh.glob("*"))
sh.rm("-rf", sh.glob("*"))
sh.mv("../config-3.10-darwin", ".")
sh.mv("../config-3.11-darwin", ".")
sh.mv("../site-packages", ".")


Expand Down
31 changes: 16 additions & 15 deletions kivy_ios/recipes/python3/configure.patch
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
diff -Naur Python-3.10.10.orig/configure Python-3.10.10/configure
--- Python-3.10.10.orig/configure 2023-02-12 15:08:28
+++ Python-3.10.10/configure 2023-02-12 15:10:45
@@ -3344,6 +3344,15 @@
--- Python-3.11.6/configure.orig 2023-10-15 12:23:31
+++ Python-3.11.6/configure 2023-10-15 12:30:23
@@ -3823,6 +3823,15 @@
*-*-cygwin*)
ac_sys_system=Cygwin
;;
Expand All @@ -17,7 +16,7 @@ diff -Naur Python-3.10.10.orig/configure Python-3.10.10/configure
*-*-vxworks*)
ac_sys_system=VxWorks
;;
@@ -3391,6 +3400,15 @@
@@ -3876,6 +3885,15 @@
_host_cpu=$host_cpu
esac
;;
Expand All @@ -33,21 +32,22 @@ diff -Naur Python-3.10.10.orig/configure Python-3.10.10/configure
*-*-cygwin*)
_host_cpu=
;;
@@ -3469,6 +3487,13 @@
@@ -3956,7 +3974,14 @@
Darwin/[6789].*)
define_xopen_source=no;;
Darwin/[12][0-9].*)
define_xopen_source=no;;
+ define_xopen_source=no;;
+ # On iOS, defining _POSIX_C_SOURCE also disables platform specific features.
+ iOS/*)
+ define_xopen_source=no;;
define_xopen_source=no;;
+ tvOS/*)
+ define_xopen_source=no;;
+ watchOS/*)
+ define_xopen_source=no;;
# On QNX 6.3.2, defining _XOPEN_SOURCE prevents netdb.h from
# defining NI_NUMERICHOST.
QNX/6.3.2)
@@ -5389,6 +5414,12 @@
@@ -6204,6 +6229,12 @@
case $ac_sys_system in #(
Darwin*) :
MULTIARCH="" ;; #(
Expand All @@ -60,7 +60,7 @@ diff -Naur Python-3.10.10.orig/configure Python-3.10.10/configure
FreeBSD*) :
MULTIARCH="" ;; #(
*) :
@@ -6249,11 +6280,17 @@
@@ -7210,11 +7241,17 @@
fi

if test "$cross_compiling" = yes; then
Expand All @@ -83,15 +83,16 @@ diff -Naur Python-3.10.10.orig/configure Python-3.10.10/configure
fi


@@ -7051,7 +7088,6 @@
@@ -8259,7 +8296,7 @@
# tweak BASECFLAGS based on compiler and platform
case $GCC in
yes)
- CFLAGS_NODIST="$CFLAGS_NODIST -std=c99"
- CFLAGS_NODIST="$CFLAGS_NODIST -std=c11"
+ CFLAGS_NODIST="$CFLAGS_NODIST -std=c11" #



{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -Wextra" >&5
$as_echo_n "checking for -Wextra... " >&6; }
@@ -11912,6 +11948,10 @@
@@ -15157,6 +15194,10 @@
then
case $ac_sys_system/$ac_sys_release in
hp*|HP*) DYNLOADFILE="dynload_hpux.o";;
Expand Down
19 changes: 0 additions & 19 deletions kivy_ios/recipes/python3/ctypes_duplicate.patch

This file was deleted.

12 changes: 0 additions & 12 deletions kivy_ios/recipes/python3/posixmodule.patch

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,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.10/:%@/lib/python3.10/site-packages:.", resourcePath, resourcePath, resourcePath, nil];
NSString *python_path = [NSString stringWithFormat:@"PYTHONPATH=%@:%@/lib/python3.11/:%@/lib/python3.11/site-packages:.", resourcePath, resourcePath, resourcePath, nil];
putenv((char *)[python_path UTF8String]);

NSString *tmp_path = [NSString stringWithFormat:@"TMP=%@/tmp", resourcePath, nil];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@
GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1";
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
HEADER_SEARCH_PATHS = (
"{{ cookiecutter.dist_dir }}/root/python3/include/python3.10/**",
"{{ cookiecutter.dist_dir }}/root/python3/include/python3.11/**",
"{{ cookiecutter.dist_dir }}/include/common/sdl2",
);
INFOPLIST_FILE = "{{ cookiecutter.project_name }}-Info.plist";
Expand Down Expand Up @@ -288,7 +288,7 @@
GCC_PREFIX_HEADER = "";
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
HEADER_SEARCH_PATHS = (
"{{ cookiecutter.dist_dir }}/root/python3/include/python3.10/**",
"{{ cookiecutter.dist_dir }}/root/python3/include/python3.11/**",
"{{ cookiecutter.dist_dir }}/include/common/sdl2",
);
INFOPLIST_FILE = "{{ cookiecutter.project_name }}-Info.plist";
Expand Down

0 comments on commit 126d1c7

Please sign in to comment.