Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public static void loadLibraries(File filesDir, File libsDir) {
// load, and it has failed, give a more
// general error
Log.v(TAG, "Library loading error: " + e.getMessage());
if (lib.startsWith("python3.14") && !foundPython) {
if (lib.startsWith("python3.5") && !foundPython) {
throw new RuntimeException("Could not load any libpythonXXX.so");
} else if (lib.startsWith("python")) {
continue;
Expand Down
60 changes: 31 additions & 29 deletions pythonforandroid/recipes/python3/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ class Python3Recipe(TargetPythonRecipe):
'''

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

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

if _p_version.major == 3 and _p_version.minor == 7:
patches += [
'patches/py3.7.1_fix-ctypes-util-find-library.patch',
'patches/py3.7.1_fix-zlib-version.patch',
]

if 8 <= _p_version.minor <= 10:
patches.append('patches/py3.8.1.patch')

if _p_version.minor >= 11:
patches.append('patches/cpython-311-ctypes-find-library.patch')

if _p_version.minor >= 14:
patches.append('patches/3.14_armv7l_fix.patch')
patches.append('patches/3.14_fix_remote_debug.patch')

if shutil.which('lld') is not None:
if _p_version.minor == 7:
patches.append("patches/py3.7.1_fix_cortex_a8.patch")
elif _p_version.minor >= 8:
patches.append("patches/py3.8.1_fix_cortex_a8.patch")

depends = ['hostpython3', 'sqlite3', 'openssl', 'libffi']
# those optional depends allow us to build python compression modules:
# - _bz2.so
Expand Down Expand Up @@ -116,11 +93,6 @@ class Python3Recipe(TargetPythonRecipe):
'ac_cv_header_bzlib_h=no',
]

if _p_version.minor >= 11:
configure_args.extend([
'--with-build-python={python_host_bin}',
])

'''The configure arguments needed to build the python recipe. Those are
used in method :meth:`build_arch` (if not overwritten like python3's
recipe does).
Expand Down Expand Up @@ -210,6 +182,32 @@ def link_version(self):
flags=flags
)

def apply_patches(self, arch, build_dir=None):

_p_version = Version(self.version)
if _p_version.major == 3 and _p_version.minor == 7:
self.patches += [
'patches/py3.7.1_fix-ctypes-util-find-library.patch',
'patches/py3.7.1_fix-zlib-version.patch',
]

if 8 <= _p_version.minor <= 10:
self.patches.append('patches/py3.8.1.patch')

if _p_version.minor >= 11:
self.patches.append('patches/cpython-311-ctypes-find-library.patch')

if _p_version.minor >= 14:
self.patches.append('patches/3.14_armv7l_fix.patch')
self.patches.append('patches/3.14_fix_remote_debug.patch')

if shutil.which('lld') is not None:
if _p_version.minor == 7:
self.patches.append("patches/py3.7.1_fix_cortex_a8.patch")
Comment on lines +205 to +206
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: probably not needed anymore since we dropped that version

elif _p_version.minor >= 8:
self.patches.append("patches/py3.8.1_fix_cortex_a8.patch")
super().apply_patches(arch, build_dir)

def include_root(self, arch_name):
return join(self.get_build_dir(arch_name), 'Include')

Expand Down Expand Up @@ -317,7 +315,11 @@ def add_flags(include_flags, link_dirs, link_libs):
env['ZLIB_VERSION'] = line.replace('#define ZLIB_VERSION ', '')
add_flags(' -I' + zlib_includes, ' -L' + zlib_lib_path, ' -lz')

if self._p_version.minor >= 13 and self.disable_gil:
_p_version = Version(self.version)
if _p_version.minor >= 11:
self.configure_args.append('--with-build-python={python_host_bin}')

if _p_version.minor >= 13 and self.disable_gil:
self.configure_args.append("--disable-gil")

return env
Expand Down
Loading