2
2
import sh
3
3
import subprocess
4
4
5
- from multiprocessing import cpu_count
6
5
from os import environ , utime
7
6
from os .path import dirname , exists , join
8
7
from pathlib import Path
@@ -56,7 +55,7 @@ class Python3Recipe(TargetPythonRecipe):
56
55
:class:`~pythonforandroid.python.GuestPythonRecipe`
57
56
'''
58
57
59
- version = '3.10.10 '
58
+ version = '3.11.5 '
60
59
url = 'https://www.python.org/ftp/python/{version}/Python-{version}.tgz'
61
60
name = 'python3'
62
61
@@ -71,17 +70,22 @@ class Python3Recipe(TargetPythonRecipe):
71
70
# Python 3.8.1 & 3.9.X
72
71
('patches/py3.8.1.patch' , version_starts_with ("3.8" )),
73
72
('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" )),
75
74
]
76
75
77
76
if shutil .which ('lld' ) is not None :
78
- patches = patches + [
77
+ patches += [
79
78
("patches/py3.7.1_fix_cortex_a8.patch" , version_starts_with ("3.7" )),
80
79
("patches/py3.8.1_fix_cortex_a8.patch" , version_starts_with ("3.8" )),
81
80
("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" )),
83
83
]
84
84
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
+
85
89
depends = ['hostpython3' , 'sqlite3' , 'openssl' , 'libffi' ]
86
90
# those optional depends allow us to build python compression modules:
87
91
# - _bz2.so
@@ -101,7 +105,12 @@ class Python3Recipe(TargetPythonRecipe):
101
105
'ac_cv_header_sys_eventfd_h=no' ,
102
106
'--prefix={prefix}' ,
103
107
'--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
+
105
114
'''The configure arguments needed to build the python recipe. Those are
106
115
used in method :meth:`build_arch` (if not overwritten like python3's
107
116
recipe does).
@@ -323,12 +332,19 @@ def build_arch(self, arch):
323
332
* (' ' .join (self .configure_args ).format (
324
333
android_host = env ['HOSTARCH' ],
325
334
android_build = android_build ,
335
+ python_host_bin = join (self .get_recipe (
336
+ 'host' + self .name , self .ctx
337
+ ).get_path_to_python (), "python3" ),
326
338
prefix = sys_prefix ,
327
339
exec_prefix = sys_exec_prefix )).split (' ' ),
328
340
_env = env )
329
341
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
330
345
shprint (
331
- sh .make , 'all' , '-j' , str (cpu_count ()),
346
+ sh .make ,
347
+ 'all' ,
332
348
'INSTSONAME={lib_name}' .format (lib_name = self ._libpython ),
333
349
_env = env
334
350
)
0 commit comments