Skip to content

Commit d8dece0

Browse files
committed
python: update to 3.11.5
1 parent 0be5572 commit d8dece0

File tree

5 files changed

+41
-10
lines changed

5 files changed

+41
-10
lines changed

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
@@ -35,7 +35,7 @@ class HostPython3Recipe(Recipe):
3535
:class:`~pythonforandroid.python.HostPythonRecipe`
3636
'''
3737

38-
version = '3.10.10'
38+
version = '3.11.5'
3939
name = 'hostpython3'
4040

4141
build_subdir = 'native-build'

pythonforandroid/recipes/python3/__init__.py

Lines changed: 23 additions & 7 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

@@ -71,17 +70,22 @@ class Python3Recipe(TargetPythonRecipe):
7170
# Python 3.8.1 & 3.9.X
7271
('patches/py3.8.1.patch', version_starts_with("3.8")),
7372
('patches/py3.8.1.patch', version_starts_with("3.9")),
74-
('patches/py3.8.1.patch', version_starts_with("3.10"))
73+
('patches/py3.8.1.patch', version_starts_with("3.10")),
7574
]
7675

7776
if shutil.which('lld') is not None:
78-
patches = patches + [
77+
patches += [
7978
("patches/py3.7.1_fix_cortex_a8.patch", version_starts_with("3.7")),
8079
("patches/py3.8.1_fix_cortex_a8.patch", version_starts_with("3.8")),
8180
("patches/py3.8.1_fix_cortex_a8.patch", version_starts_with("3.9")),
82-
("patches/py3.8.1_fix_cortex_a8.patch", version_starts_with("3.10"))
81+
("patches/py3.8.1_fix_cortex_a8.patch", version_starts_with("3.10")),
82+
("patches/py3.8.1_fix_cortex_a8.patch", version_starts_with("3.11")),
8383
]
8484

85+
# ctypes pythonapi fix.
86+
# Taken from : https://github.com/gabomdq/ignifuga/blob/master/tools/patches/python.android.diff
87+
patches += ["patches/ctypes-pythonapi.patch"]
88+
8589
depends = ['hostpython3', 'sqlite3', 'openssl', 'libffi']
8690
# those optional depends allow us to build python compression modules:
8791
# - _bz2.so
@@ -101,7 +105,12 @@ class Python3Recipe(TargetPythonRecipe):
101105
'ac_cv_header_sys_eventfd_h=no',
102106
'--prefix={prefix}',
103107
'--exec-prefix={exec_prefix}',
104-
'--enable-loadable-sqlite-extensions')
108+
'--enable-loadable-sqlite-extensions'
109+
)
110+
111+
if version_starts_with("3.11"):
112+
configure_args += ('--with-build-python={python_host_bin}',)
113+
105114
'''The configure arguments needed to build the python recipe. Those are
106115
used in method :meth:`build_arch` (if not overwritten like python3's
107116
recipe does).
@@ -323,12 +332,19 @@ def build_arch(self, arch):
323332
*(' '.join(self.configure_args).format(
324333
android_host=env['HOSTARCH'],
325334
android_build=android_build,
335+
python_host_bin=join(self.get_recipe(
336+
'host' + self.name, self.ctx
337+
).get_path_to_python(), "python3"),
326338
prefix=sys_prefix,
327339
exec_prefix=sys_exec_prefix)).split(' '),
328340
_env=env)
329341

342+
# Python build does not seem to play well with make -j option from Python 3.11 and onwards
343+
# Before losing some time, please check issue
344+
# https://github.com/python/cpython/issues/101295 , as the root cause looks similar
330345
shprint(
331-
sh.make, 'all', '-j', str(cpu_count()),
346+
sh.make,
347+
'all',
332348
'INSTSONAME={lib_name}'.format(lib_name=self._libpython),
333349
_env=env
334350
)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--- Python-3.11.5/Lib/ctypes/__init__.py 2023-08-24 17:39:18.000000000 +0530
2+
+++ Python-3.11.5.mod/Lib/ctypes/__init__.py 2023-11-14 21:35:03.782777438 +0530
3+
@@ -460,10 +460,8 @@
4+
5+
if _os.name == "nt":
6+
pythonapi = PyDLL("python dll", None, _sys.dllhandle)
7+
-elif _sys.platform == "cygwin":
8+
- pythonapi = PyDLL("libpython%d.%d.dll" % _sys.version_info[:2])
9+
else:
10+
- pythonapi = PyDLL(None)
11+
+ pythonapi = PyDLL("libpython%d.%d.so" % _sys.version_info[:2])
12+
13+
14+
if _os.name == "nt":

0 commit comments

Comments
 (0)