From 89a05ba5a1d2432e7e7d355187b8e7be3659288e Mon Sep 17 00:00:00 2001 From: T-Dynamos Date: Sat, 8 Jul 2023 12:10:18 +0530 Subject: [PATCH] python: update to 3.11.5 --- .../java/org/kivy/android/PythonUtil.java | 3 +- pythonforandroid/recipes/cython/__init__.py | 2 +- .../recipes/hostpython3/__init__.py | 2 +- pythonforandroid/recipes/python3/__init__.py | 28 +++++++++++++++---- .../patches/py3.11.4_fix_cortex_a8.patch | 11 ++++++++ 5 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 pythonforandroid/recipes/python3/patches/py3.11.4_fix_cortex_a8.patch diff --git a/pythonforandroid/bootstraps/common/build/src/main/java/org/kivy/android/PythonUtil.java b/pythonforandroid/bootstraps/common/build/src/main/java/org/kivy/android/PythonUtil.java index 5bc23bacf4..cc04d83f6b 100644 --- a/pythonforandroid/bootstraps/common/build/src/main/java/org/kivy/android/PythonUtil.java +++ b/pythonforandroid/bootstraps/common/build/src/main/java/org/kivy/android/PythonUtil.java @@ -55,6 +55,7 @@ protected static ArrayList getLibraries(File libsDir) { libsList.add("python3.8"); libsList.add("python3.9"); libsList.add("python3.10"); + libsList.add("python3.11"); libsList.add("main"); return libsList; } @@ -74,7 +75,7 @@ public static void loadLibraries(File filesDir, File libsDir) { // load, and it has failed, give a more // general error Log.v(TAG, "Library loading error: " + e.getMessage()); - if (lib.startsWith("python3.10") && !foundPython) { + if (lib.startsWith("python3.11") && !foundPython) { throw new RuntimeException("Could not load any libpythonXXX.so"); } else if (lib.startsWith("python")) { continue; diff --git a/pythonforandroid/recipes/cython/__init__.py b/pythonforandroid/recipes/cython/__init__.py index 9135e187ca..b8bac0ae18 100644 --- a/pythonforandroid/recipes/cython/__init__.py +++ b/pythonforandroid/recipes/cython/__init__.py @@ -3,7 +3,7 @@ class CythonRecipe(CompiledComponentsPythonRecipe): - version = '0.29.28' + version = '0.29.36' url = 'https://github.com/cython/cython/archive/{version}.tar.gz' site_packages_name = 'cython' depends = ['setuptools'] diff --git a/pythonforandroid/recipes/hostpython3/__init__.py b/pythonforandroid/recipes/hostpython3/__init__.py index ee53b6ef09..9ba4580019 100644 --- a/pythonforandroid/recipes/hostpython3/__init__.py +++ b/pythonforandroid/recipes/hostpython3/__init__.py @@ -35,7 +35,7 @@ class HostPython3Recipe(Recipe): :class:`~pythonforandroid.python.HostPythonRecipe` ''' - version = '3.10.10' + version = '3.11.5' name = 'hostpython3' build_subdir = 'native-build' diff --git a/pythonforandroid/recipes/python3/__init__.py b/pythonforandroid/recipes/python3/__init__.py index 387922718e..afb9a2f2c4 100644 --- a/pythonforandroid/recipes/python3/__init__.py +++ b/pythonforandroid/recipes/python3/__init__.py @@ -56,7 +56,7 @@ class Python3Recipe(TargetPythonRecipe): :class:`~pythonforandroid.python.GuestPythonRecipe` ''' - version = '3.10.10' + version = '3.11.5' url = 'https://www.python.org/ftp/python/{version}/Python-{version}.tgz' name = 'python3' @@ -71,7 +71,7 @@ class Python3Recipe(TargetPythonRecipe): # Python 3.8.1 & 3.9.X ('patches/py3.8.1.patch', version_starts_with("3.8")), ('patches/py3.8.1.patch', version_starts_with("3.9")), - ('patches/py3.8.1.patch', version_starts_with("3.10")) + ('patches/py3.8.1.patch', version_starts_with("3.10")), ] if shutil.which('lld') is not None: @@ -79,7 +79,8 @@ class Python3Recipe(TargetPythonRecipe): ("patches/py3.7.1_fix_cortex_a8.patch", version_starts_with("3.7")), ("patches/py3.8.1_fix_cortex_a8.patch", version_starts_with("3.8")), ("patches/py3.8.1_fix_cortex_a8.patch", version_starts_with("3.9")), - ("patches/py3.8.1_fix_cortex_a8.patch", version_starts_with("3.10")) + ("patches/py3.8.1_fix_cortex_a8.patch", version_starts_with("3.10")), + ("patches/py3.11.4_fix_cortex_a8.patch", version_starts_with("3.11")) ] depends = ['hostpython3', 'sqlite3', 'openssl', 'libffi'] @@ -101,7 +102,12 @@ class Python3Recipe(TargetPythonRecipe): 'ac_cv_header_sys_eventfd_h=no', '--prefix={prefix}', '--exec-prefix={exec_prefix}', - '--enable-loadable-sqlite-extensions') + '--enable-loadable-sqlite-extensions' + ) + + if version_starts_with("3.11"): + configure_args += ('--with-build-python={python_host_bin}',) + '''The configure arguments needed to build the python recipe. Those are used in method :meth:`build_arch` (if not overwritten like python3's recipe does). @@ -219,6 +225,13 @@ def get_recipe_env(self, arch=None, with_flags_in_cc=True): warning('lld not found, linking without it. ' 'Consider installing lld if linker errors occur.') + if 'MAKEFLAGS' in env.keys() and version_starts_with("3.11"): + if "-j" in env['MAKEFLAGS']: + __ = env['MAKEFLAGS'].split(" ") + __.pop(__.index("-j") + 1) # -j 10, here pop 10 + __.pop(__.index("-j")) # here pop '-j' + env["MAKEFLAGS"] = " ".join(__) + return env def set_libs_flags(self, env, arch): @@ -323,12 +336,17 @@ def build_arch(self, arch): *(' '.join(self.configure_args).format( android_host=env['HOSTARCH'], android_build=android_build, + python_host_bin=join(self.get_recipe( + 'host' + self.name, self.ctx + ).get_path_to_python(), "python3"), prefix=sys_prefix, exec_prefix=sys_exec_prefix)).split(' '), _env=env) + # disable parallel build on 3.11 to fix: + # ld: error: unable to find library -lpython3.11 shprint( - sh.make, 'all', '-j', str(cpu_count()), + sh.make, 'all', '-j', (str(cpu_count()) if not version_starts_with("3.11") else "1"), 'INSTSONAME={lib_name}'.format(lib_name=self._libpython), _env=env ) diff --git a/pythonforandroid/recipes/python3/patches/py3.11.4_fix_cortex_a8.patch b/pythonforandroid/recipes/python3/patches/py3.11.4_fix_cortex_a8.patch new file mode 100644 index 0000000000..e799135915 --- /dev/null +++ b/pythonforandroid/recipes/python3/patches/py3.11.4_fix_cortex_a8.patch @@ -0,0 +1,11 @@ +--- Python-3.11.4/configure 2023-06-07 03:30:27.000000000 +0530 ++++ Python-3.11.4.mod/configure 2023-07-08 11:51:11.031135937 +0530 +@@ -6994,7 +6994,7 @@ + printf "%s\n" "$_arm_arch" >&6; } + if test "$_arm_arch" = 7; then + BASECFLAGS="${BASECFLAGS} -mfloat-abi=softfp -mfpu=vfpv3-d16" +- LDFLAGS="${LDFLAGS} -march=armv7-a -Wl,--fix-cortex-a8" ++ LDFLAGS="${LDFLAGS} -march=armv7-a" + fi + else + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: not Android" >&5