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
@@ -71,15 +70,17 @@ 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" )),
74+ ('patches/cpython-311-ctypes-find-library.patch' , version_starts_with ("3.11" )),
7575 ]
7676
7777 if shutil .which ('lld' ) is not None :
78- patches = patches + [
78+ patches += [
7979 ("patches/py3.7.1_fix_cortex_a8.patch" , version_starts_with ("3.7" )),
8080 ("patches/py3.8.1_fix_cortex_a8.patch" , version_starts_with ("3.8" )),
8181 ("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" ))
82+ ("patches/py3.8.1_fix_cortex_a8.patch" , version_starts_with ("3.10" )),
83+ ("patches/py3.8.1_fix_cortex_a8.patch" , version_starts_with ("3.11" )),
8384 ]
8485
8586 depends = ['hostpython3' , 'sqlite3' , 'openssl' , 'libffi' ]
@@ -101,7 +102,12 @@ class Python3Recipe(TargetPythonRecipe):
101102 'ac_cv_header_sys_eventfd_h=no' ,
102103 '--prefix={prefix}' ,
103104 '--exec-prefix={exec_prefix}' ,
104- '--enable-loadable-sqlite-extensions' )
105+ '--enable-loadable-sqlite-extensions'
106+ )
107+
108+ if version_starts_with ("3.11" ):
109+ configure_args += ('--with-build-python={python_host_bin}' ,)
110+
105111 '''The configure arguments needed to build the python recipe. Those are
106112 used in method :meth:`build_arch` (if not overwritten like python3's
107113 recipe does).
@@ -323,12 +329,19 @@ def build_arch(self, arch):
323329 * (' ' .join (self .configure_args ).format (
324330 android_host = env ['HOSTARCH' ],
325331 android_build = android_build ,
332+ python_host_bin = join (self .get_recipe (
333+ 'host' + self .name , self .ctx
334+ ).get_path_to_python (), "python3" ),
326335 prefix = sys_prefix ,
327336 exec_prefix = sys_exec_prefix )).split (' ' ),
328337 _env = env )
329338
339+ # Python build does not seem to play well with make -j option from Python 3.11 and onwards
340+ # Before losing some time, please check issue
341+ # https://github.com/python/cpython/issues/101295 , as the root cause looks similar
330342 shprint (
331- sh .make , 'all' , '-j' , str (cpu_count ()),
343+ sh .make ,
344+ 'all' ,
332345 'INSTSONAME={lib_name}' .format (lib_name = self ._libpython ),
333346 _env = env
334347 )
0 commit comments