22import sh
33import subprocess
44
5- from multiprocessing import cpu_count
65from os import environ , utime
76from os .path import dirname , exists , join
87from 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 )
0 commit comments