Skip to content

Commit a01269f

Browse files
T-DynamosSomberNight
authored andcommitted
python: update to 3.11.5
cherry-pick of kivy@78db832
1 parent e91310f commit a01269f

5 files changed

Lines changed: 43 additions & 9 deletions

File tree

pythonforandroid/bootstraps/common/build/src/main/java/org/kivy/android/PythonUtil.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ protected static ArrayList<String> getLibraries(File libsDir) {
5555
libsList.add("python3.8");
5656
libsList.add("python3.9");
5757
libsList.add("python3.10");
58+
libsList.add("python3.11");
5859
libsList.add("main");
5960
return libsList;
6061
}
@@ -74,7 +75,7 @@ public static void loadLibraries(File filesDir, File libsDir) {
7475
// load, and it has failed, give a more
7576
// general error
7677
Log.v(TAG, "Library loading error: " + e.getMessage());
77-
if (lib.startsWith("python3.10") && !foundPython) {
78+
if (lib.startsWith("python3.11") && !foundPython) {
7879
throw new RuntimeException("Could not load any libpythonXXX.so");
7980
} else if (lib.startsWith("python")) {
8081
continue;

pythonforandroid/recipes/cython/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
class CythonRecipe(CompiledComponentsPythonRecipe):
55

6-
version = '0.29.28'
6+
version = '0.29.36'
77
url = 'https://github.com/cython/cython/archive/{version}.tar.gz'
88
site_packages_name = 'cython'
99
depends = ['setuptools']

pythonforandroid/recipes/hostpython3/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class HostPython3Recipe(Recipe):
3636
:class:`~pythonforandroid.python.HostPythonRecipe`
3737
'''
3838

39-
version = '3.10.10'
39+
version = '3.11.5'
4040
name = 'hostpython3'
4141

4242
build_subdir = 'native-build'

pythonforandroid/recipes/python3/__init__.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
import sh
33
import subprocess
44

5-
from multiprocessing import cpu_count
65
from os import environ, utime
76
from os.path import dirname, exists, join
87
from pathlib import Path
@@ -56,7 +55,7 @@ class Python3Recipe(TargetPythonRecipe):
5655
:class:`~pythonforandroid.python.GuestPythonRecipe`
5756
'''
5857

59-
version = '3.10.10'
58+
version = '3.11.5'
6059
url = 'https://www.python.org/ftp/python/{version}/Python-{version}.tgz'
6160
name = 'python3'
6261

@@ -75,14 +74,17 @@ class Python3Recipe(TargetPythonRecipe):
7574

7675
('patches/py3.10_reproducible-pyc.diff', version_starts_with("3.10")),
7776
('patches/py3.10_reproducible-marshal_flagref.patch', version_starts_with("3.10")),
77+
78+
('patches/cpython-311-ctypes-find-library.patch', version_starts_with("3.11")),
7879
]
7980

8081
if shutil.which('lld') is not None:
81-
patches = patches + [
82+
patches += [
8283
("patches/py3.7.1_fix_cortex_a8.patch", version_starts_with("3.7")),
8384
("patches/py3.8.1_fix_cortex_a8.patch", version_starts_with("3.8")),
8485
("patches/py3.8.1_fix_cortex_a8.patch", version_starts_with("3.9")),
85-
("patches/py3.8.1_fix_cortex_a8.patch", version_starts_with("3.10"))
86+
("patches/py3.8.1_fix_cortex_a8.patch", version_starts_with("3.10")),
87+
("patches/py3.8.1_fix_cortex_a8.patch", version_starts_with("3.11")),
8688
]
8789

8890
depends = ['hostpython3', 'sqlite3', 'openssl', 'libffi']
@@ -104,7 +106,12 @@ class Python3Recipe(TargetPythonRecipe):
104106
'ac_cv_header_sys_eventfd_h=no',
105107
'--prefix={prefix}',
106108
'--exec-prefix={exec_prefix}',
107-
'--enable-loadable-sqlite-extensions')
109+
'--enable-loadable-sqlite-extensions'
110+
)
111+
112+
if version_starts_with("3.11"):
113+
configure_args += ('--with-build-python={python_host_bin}',)
114+
108115
'''The configure arguments needed to build the python recipe. Those are
109116
used in method :meth:`build_arch` (if not overwritten like python3's
110117
recipe does).
@@ -326,12 +333,19 @@ def build_arch(self, arch):
326333
*(' '.join(self.configure_args).format(
327334
android_host=env['HOSTARCH'],
328335
android_build=android_build,
336+
python_host_bin=join(self.get_recipe(
337+
'host' + self.name, self.ctx
338+
).get_path_to_python(), "python3"),
329339
prefix=sys_prefix,
330340
exec_prefix=sys_exec_prefix)).split(' '),
331341
_env=env)
332342

343+
# Python build does not seem to play well with make -j option from Python 3.11 and onwards
344+
# Before losing some time, please check issue
345+
# https://github.com/python/cpython/issues/101295 , as the root cause looks similar
333346
shprint(
334-
sh.make, 'all', '-j', str(cpu_count()),
347+
sh.make,
348+
'all',
335349
'INSTSONAME={lib_name}'.format(lib_name=self._libpython),
336350
_env=env
337351
)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--- Python-3.11.5/Lib/ctypes/util.py 2023-08-24 17:39:18.000000000 +0530
2+
+++ Python-3.11.5.mod/Lib/ctypes/util.py 2023-11-18 22:12:17.356160615 +0530
3+
@@ -4,7 +4,15 @@
4+
import sys
5+
6+
# find_library(name) returns the pathname of a library, or None.
7+
-if os.name == "nt":
8+
+
9+
+# This patch overrides the find_library to look in the right places on
10+
+# Android
11+
+if True:
12+
+ from android._ctypes_library_finder import find_library as _find_lib
13+
+ def find_library(name):
14+
+ return _find_lib(name)
15+
+
16+
+elif os.name == "nt":
17+
18+
def _get_build_version():
19+
"""Return the version of MSVC that was used to build Python.

0 commit comments

Comments
 (0)