Skip to content

Commit bf4737a

Browse files
Fixed Python version support.
1 parent f4f08e6 commit bf4737a

1 file changed

Lines changed: 33 additions & 24 deletions

File tree

pythonforandroid/recipes/python3/__init__.py

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ class Python3Recipe(TargetPythonRecipe):
5555
'''
5656

5757
version = '3.14.2'
58-
_p_version = Version(version)
5958
url = 'https://github.com/python/cpython/archive/refs/tags/v{version}.tar.gz'
6059
name = 'python3'
6160

@@ -64,28 +63,6 @@ class Python3Recipe(TargetPythonRecipe):
6463
'patches/reproducible-buildinfo.diff',
6564
]
6665

67-
if _p_version.major == 3 and _p_version.minor == 7:
68-
patches += [
69-
'patches/py3.7.1_fix-ctypes-util-find-library.patch',
70-
'patches/py3.7.1_fix-zlib-version.patch',
71-
]
72-
73-
if 8 <= _p_version.minor <= 10:
74-
patches.append('patches/py3.8.1.patch')
75-
76-
if _p_version.minor >= 11:
77-
patches.append('patches/cpython-311-ctypes-find-library.patch')
78-
79-
if _p_version.minor >= 14:
80-
patches.append('patches/3.14_armv7l_fix.patch')
81-
patches.append('patches/3.14_fix_remote_debug.patch')
82-
83-
if shutil.which('lld') is not None:
84-
if _p_version.minor == 7:
85-
patches.append("patches/py3.7.1_fix_cortex_a8.patch")
86-
elif _p_version.minor >= 8:
87-
patches.append("patches/py3.8.1_fix_cortex_a8.patch")
88-
8966
depends = ['hostpython3', 'sqlite3', 'openssl', 'libffi']
9067
# those optional depends allow us to build python compression modules:
9168
# - _bz2.so
@@ -210,6 +187,32 @@ def link_version(self):
210187
flags=flags
211188
)
212189

190+
def apply_patches(self, arch, build_dir=None):
191+
192+
_p_version = Version(self.version)
193+
if _p_version.major == 3 and _p_version.minor == 7:
194+
self.patches += [
195+
'patches/py3.7.1_fix-ctypes-util-find-library.patch',
196+
'patches/py3.7.1_fix-zlib-version.patch',
197+
]
198+
199+
if 8 <= _p_version.minor <= 10:
200+
self.patches.append('patches/py3.8.1.patch')
201+
202+
if _p_version.minor >= 11:
203+
self.patches.append('patches/cpython-311-ctypes-find-library.patch')
204+
205+
if _p_version.minor >= 14:
206+
self.patches.append('patches/3.14_armv7l_fix.patch')
207+
self.patches.append('patches/3.14_fix_remote_debug.patch')
208+
209+
if shutil.which('lld') is not None:
210+
if _p_version.minor == 7:
211+
self.patches.append("patches/py3.7.1_fix_cortex_a8.patch")
212+
elif _p_version.minor >= 8:
213+
self.patches.append("patches/py3.8.1_fix_cortex_a8.patch")
214+
super().__init__(arch, build_dir)
215+
213216
def include_root(self, arch_name):
214217
return join(self.get_build_dir(arch_name), 'Include')
215218

@@ -317,7 +320,13 @@ def add_flags(include_flags, link_dirs, link_libs):
317320
env['ZLIB_VERSION'] = line.replace('#define ZLIB_VERSION ', '')
318321
add_flags(' -I' + zlib_includes, ' -L' + zlib_lib_path, ' -lz')
319322

320-
if self._p_version.minor >= 13 and self.disable_gil:
323+
_p_version = Version(self.version)
324+
if _p_version.minor >= 11:
325+
configure_args.extend([
326+
'--with-build-python={python_host_bin}',
327+
])
328+
329+
if _p_version.minor >= 13 and self.disable_gil:
321330
self.configure_args.append("--disable-gil")
322331

323332
return env

0 commit comments

Comments
 (0)