From f4f08e666e67d221da42251e7bf3d9e131d19883 Mon Sep 17 00:00:00 2001 From: Leonid <87101242+GvozdevLeonid@users.noreply.github.com> Date: Sat, 21 Feb 2026 20:50:05 +0100 Subject: [PATCH 01/10] Fixed a bug with Python version selection and library loading. --- .../common/build/src/main/java/org/kivy/android/PythonUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 b40694260..3490211e6 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 @@ -59,7 +59,7 @@ protected static ArrayList getLibraries(File libsDir) { addLibraryIfExists(libsList, name, libsDir); } - for (int v = 14; v >= 5; v--) { + for (int v = 5; v <= 3.14; v++) { libsList.add("python3." + v + (v <= 7 ? "m" : "")); } From bf4737a9b36f6eeeef5437dc31a130e730483428 Mon Sep 17 00:00:00 2001 From: Leonid <87101242+GvozdevLeonid@users.noreply.github.com> Date: Sat, 21 Feb 2026 21:00:49 +0100 Subject: [PATCH 02/10] Fixed Python version support. --- pythonforandroid/recipes/python3/__init__.py | 57 +++++++++++--------- 1 file changed, 33 insertions(+), 24 deletions(-) diff --git a/pythonforandroid/recipes/python3/__init__.py b/pythonforandroid/recipes/python3/__init__.py index 3ff1f147b..b4d40c375 100644 --- a/pythonforandroid/recipes/python3/__init__.py +++ b/pythonforandroid/recipes/python3/__init__.py @@ -55,7 +55,6 @@ class Python3Recipe(TargetPythonRecipe): ''' version = '3.14.2' - _p_version = Version(version) url = 'https://github.com/python/cpython/archive/refs/tags/v{version}.tar.gz' name = 'python3' @@ -64,28 +63,6 @@ class Python3Recipe(TargetPythonRecipe): 'patches/reproducible-buildinfo.diff', ] - if _p_version.major == 3 and _p_version.minor == 7: - patches += [ - 'patches/py3.7.1_fix-ctypes-util-find-library.patch', - 'patches/py3.7.1_fix-zlib-version.patch', - ] - - if 8 <= _p_version.minor <= 10: - patches.append('patches/py3.8.1.patch') - - if _p_version.minor >= 11: - patches.append('patches/cpython-311-ctypes-find-library.patch') - - if _p_version.minor >= 14: - patches.append('patches/3.14_armv7l_fix.patch') - patches.append('patches/3.14_fix_remote_debug.patch') - - if shutil.which('lld') is not None: - if _p_version.minor == 7: - patches.append("patches/py3.7.1_fix_cortex_a8.patch") - elif _p_version.minor >= 8: - patches.append("patches/py3.8.1_fix_cortex_a8.patch") - depends = ['hostpython3', 'sqlite3', 'openssl', 'libffi'] # those optional depends allow us to build python compression modules: # - _bz2.so @@ -210,6 +187,32 @@ def link_version(self): flags=flags ) + def apply_patches(self, arch, build_dir=None): + + _p_version = Version(self.version) + if _p_version.major == 3 and _p_version.minor == 7: + self.patches += [ + 'patches/py3.7.1_fix-ctypes-util-find-library.patch', + 'patches/py3.7.1_fix-zlib-version.patch', + ] + + if 8 <= _p_version.minor <= 10: + self.patches.append('patches/py3.8.1.patch') + + if _p_version.minor >= 11: + self.patches.append('patches/cpython-311-ctypes-find-library.patch') + + if _p_version.minor >= 14: + self.patches.append('patches/3.14_armv7l_fix.patch') + self.patches.append('patches/3.14_fix_remote_debug.patch') + + if shutil.which('lld') is not None: + if _p_version.minor == 7: + self.patches.append("patches/py3.7.1_fix_cortex_a8.patch") + elif _p_version.minor >= 8: + self.patches.append("patches/py3.8.1_fix_cortex_a8.patch") + super().__init__(arch, build_dir) + def include_root(self, arch_name): return join(self.get_build_dir(arch_name), 'Include') @@ -317,7 +320,13 @@ def add_flags(include_flags, link_dirs, link_libs): env['ZLIB_VERSION'] = line.replace('#define ZLIB_VERSION ', '') add_flags(' -I' + zlib_includes, ' -L' + zlib_lib_path, ' -lz') - if self._p_version.minor >= 13 and self.disable_gil: + _p_version = Version(self.version) + if _p_version.minor >= 11: + configure_args.extend([ + '--with-build-python={python_host_bin}', + ]) + + if _p_version.minor >= 13 and self.disable_gil: self.configure_args.append("--disable-gil") return env From c787f271337210625a61b78031e737f490130ec1 Mon Sep 17 00:00:00 2001 From: Leonid <87101242+GvozdevLeonid@users.noreply.github.com> Date: Sat, 21 Feb 2026 21:17:55 +0100 Subject: [PATCH 03/10] Fixed Python version support. Remove conditional build argument for Python version >= 11 --- pythonforandroid/recipes/python3/__init__.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/pythonforandroid/recipes/python3/__init__.py b/pythonforandroid/recipes/python3/__init__.py index b4d40c375..7aa166287 100644 --- a/pythonforandroid/recipes/python3/__init__.py +++ b/pythonforandroid/recipes/python3/__init__.py @@ -93,11 +93,6 @@ class Python3Recipe(TargetPythonRecipe): 'ac_cv_header_bzlib_h=no', ] - if _p_version.minor >= 11: - configure_args.extend([ - '--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). From 4f7e6a6491a7ff61fec85ef0f3413260480a131f Mon Sep 17 00:00:00 2001 From: Leonid <87101242+GvozdevLeonid@users.noreply.github.com> Date: Sat, 21 Feb 2026 21:23:40 +0100 Subject: [PATCH 04/10] fixed typo --- pythonforandroid/recipes/python3/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pythonforandroid/recipes/python3/__init__.py b/pythonforandroid/recipes/python3/__init__.py index 7aa166287..eb378ef80 100644 --- a/pythonforandroid/recipes/python3/__init__.py +++ b/pythonforandroid/recipes/python3/__init__.py @@ -206,7 +206,7 @@ def apply_patches(self, arch, build_dir=None): self.patches.append("patches/py3.7.1_fix_cortex_a8.patch") elif _p_version.minor >= 8: self.patches.append("patches/py3.8.1_fix_cortex_a8.patch") - super().__init__(arch, build_dir) + super().apply_patches(arch, build_dir) def include_root(self, arch_name): return join(self.get_build_dir(arch_name), 'Include') From a870db2455d4f6655d995e244526739a6375651e Mon Sep 17 00:00:00 2001 From: Leonid <87101242+GvozdevLeonid@users.noreply.github.com> Date: Sat, 21 Feb 2026 21:39:53 +0100 Subject: [PATCH 05/10] Fix issue --- .../build/src/main/java/org/kivy/android/PythonUtil.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 3490211e6..e8aee768c 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 @@ -59,7 +59,7 @@ protected static ArrayList getLibraries(File libsDir) { addLibraryIfExists(libsList, name, libsDir); } - for (int v = 5; v <= 3.14; v++) { + for (int v = 14; v >= 5; v--) { libsList.add("python3." + v + (v <= 7 ? "m" : "")); } @@ -85,7 +85,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.14") && !foundPython) { + if (lib.startsWith("python3.5") && !foundPython) { throw new RuntimeException("Could not load any libpythonXXX.so"); } else if (lib.startsWith("python")) { continue; From 285c0a800e6f6dcdea4e20638daeb2cb4fadbd70 Mon Sep 17 00:00:00 2001 From: Leonid <87101242+GvozdevLeonid@users.noreply.github.com> Date: Sat, 21 Feb 2026 22:11:00 +0100 Subject: [PATCH 06/10] fixed issue --- pythonforandroid/recipes/python3/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pythonforandroid/recipes/python3/__init__.py b/pythonforandroid/recipes/python3/__init__.py index eb378ef80..94f199129 100644 --- a/pythonforandroid/recipes/python3/__init__.py +++ b/pythonforandroid/recipes/python3/__init__.py @@ -317,7 +317,7 @@ def add_flags(include_flags, link_dirs, link_libs): _p_version = Version(self.version) if _p_version.minor >= 11: - configure_args.extend([ + self.configure_args.extend([ '--with-build-python={python_host_bin}', ]) From bdb5e059af8b2e4415008833719d437280bd3cd8 Mon Sep 17 00:00:00 2001 From: Leonid <87101242+GvozdevLeonid@users.noreply.github.com> Date: Sat, 21 Feb 2026 22:12:27 +0100 Subject: [PATCH 07/10] Simplify configuration arguments --- pythonforandroid/recipes/python3/__init__.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pythonforandroid/recipes/python3/__init__.py b/pythonforandroid/recipes/python3/__init__.py index 94f199129..a215a99ea 100644 --- a/pythonforandroid/recipes/python3/__init__.py +++ b/pythonforandroid/recipes/python3/__init__.py @@ -317,9 +317,7 @@ def add_flags(include_flags, link_dirs, link_libs): _p_version = Version(self.version) if _p_version.minor >= 11: - self.configure_args.extend([ - '--with-build-python={python_host_bin}', - ]) + self.configure_args.append('--with-build-python={python_host_bin}') if _p_version.minor >= 13 and self.disable_gil: self.configure_args.append("--disable-gil") From 81f185e7baaccd84ae57511854c8be9a513ae282 Mon Sep 17 00:00:00 2001 From: Leonid <87101242+GvozdevLeonid@users.noreply.github.com> Date: Sun, 22 Feb 2026 15:05:04 +0100 Subject: [PATCH 08/10] fixed flake8 issues --- pythonforandroid/recipes/python3/__init__.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pythonforandroid/recipes/python3/__init__.py b/pythonforandroid/recipes/python3/__init__.py index a215a99ea..c3fab0738 100644 --- a/pythonforandroid/recipes/python3/__init__.py +++ b/pythonforandroid/recipes/python3/__init__.py @@ -190,17 +190,17 @@ def apply_patches(self, arch, build_dir=None): 'patches/py3.7.1_fix-ctypes-util-find-library.patch', 'patches/py3.7.1_fix-zlib-version.patch', ] - + if 8 <= _p_version.minor <= 10: self.patches.append('patches/py3.8.1.patch') - + if _p_version.minor >= 11: self.patches.append('patches/cpython-311-ctypes-find-library.patch') - + if _p_version.minor >= 14: self.patches.append('patches/3.14_armv7l_fix.patch') self.patches.append('patches/3.14_fix_remote_debug.patch') - + if shutil.which('lld') is not None: if _p_version.minor == 7: self.patches.append("patches/py3.7.1_fix_cortex_a8.patch") From c681ef99f9f8b3ab787c7f4bdc90d59496045c4e Mon Sep 17 00:00:00 2001 From: Leonid <87101242+GvozdevLeonid@users.noreply.github.com> Date: Sun, 22 Feb 2026 22:29:14 +0100 Subject: [PATCH 09/10] Increased the minimum python version to 3.8 --- .../build/src/main/java/org/kivy/android/PythonUtil.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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 e8aee768c..42f4debb5 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 @@ -59,8 +59,8 @@ protected static ArrayList getLibraries(File libsDir) { addLibraryIfExists(libsList, name, libsDir); } - for (int v = 14; v >= 5; v--) { - libsList.add("python3." + v + (v <= 7 ? "m" : "")); + for (int v = 14; v >= 8; v--) { + libsList.add("python3." + v); } libsList.add("main"); @@ -85,7 +85,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.5") && !foundPython) { + if (lib.startsWith("python3.8") && !foundPython) { throw new RuntimeException("Could not load any libpythonXXX.so"); } else if (lib.startsWith("python")) { continue; From 89bb823ed1f80f187bdf47b0cc0c2b5a6ec4de96 Mon Sep 17 00:00:00 2001 From: Leonid <87101242+GvozdevLeonid@users.noreply.github.com> Date: Sun, 22 Feb 2026 22:35:33 +0100 Subject: [PATCH 10/10] simple solution to remove duplicates from patches and configure_args Ensure patches and configure arguments are unique. --- pythonforandroid/recipes/python3/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pythonforandroid/recipes/python3/__init__.py b/pythonforandroid/recipes/python3/__init__.py index c3fab0738..e36e0b28a 100644 --- a/pythonforandroid/recipes/python3/__init__.py +++ b/pythonforandroid/recipes/python3/__init__.py @@ -206,6 +206,8 @@ def apply_patches(self, arch, build_dir=None): self.patches.append("patches/py3.7.1_fix_cortex_a8.patch") elif _p_version.minor >= 8: self.patches.append("patches/py3.8.1_fix_cortex_a8.patch") + + self.patches = list(set(self.patches)) super().apply_patches(arch, build_dir) def include_root(self, arch_name): @@ -322,6 +324,8 @@ def add_flags(include_flags, link_dirs, link_libs): if _p_version.minor >= 13 and self.disable_gil: self.configure_args.append("--disable-gil") + self.configure_args = list(set(self.configure_args)) + return env def build_arch(self, arch):