Skip to content

Commit d7e9d9d

Browse files
committed
Added infrastructure for recipe-version-dependent patching
1 parent d2714df commit d7e9d9d

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

pythonforandroid/patching.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from os import uname
2+
from distutils.version import LooseVersion
23

34

45
def check_all(*callables):
@@ -69,3 +70,15 @@ def is_ndk(ndk):
6970
def is_x(recipe, **kwargs):
7071
return recipe.ctx.ndk == ndk
7172
return is_x
73+
74+
def is_version_gt(version):
75+
def is_x(recipe, **kwargs):
76+
return LooseVersion(recipe.version) > version
77+
78+
def is_version_gt(version):
79+
def is_x(recipe, **kwargs):
80+
return LooseVersion(recipe.version) < version
81+
82+
def version_starts_with(version):
83+
def is_x(recipe, **kwargs):
84+
return recipe.version.startswith(version)

pythonforandroid/recipes/python3/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import sh
22
from pythonforandroid.python import GuestPythonRecipe
33
from pythonforandroid.recipe import Recipe
4+
from pythonforandroid.patching import version_starts_with
45

56

67
class Python3Recipe(GuestPythonRecipe):
@@ -22,10 +23,14 @@ class Python3Recipe(GuestPythonRecipe):
2223
url = 'https://www.python.org/ftp/python/{version}/Python-{version}.tgz'
2324
name = 'python3'
2425

25-
# patches = ['patches/fix-ctypes-util-find-library.patch',
26-
# 'patches/fix-zlib-version.patch']
26+
patches = [
27+
# Python 3.7.1
28+
('patches/fix-ctypes-util-find-library.patch', version_starts_with("3.7")),
29+
('patches/fix-zlib-version.patch', version_starts_with("3.7"))
2730

28-
patches = ['patches/py381.patch']
31+
# Python 3.8.1
32+
('patches/py381.patch', version_starts_with("3.8"))
33+
]
2934

3035
if sh.which('lld') is not None:
3136
raise RuntimeError("!!!")

pythonforandroid/recommendations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def check_ndk_api(ndk_api, android_api):
187187

188188

189189
MIN_PYTHON_MAJOR_VERSION = 3
190-
MIN_PYTHON_MINOR_VERSION = 4
190+
MIN_PYTHON_MINOR_VERSION = 6
191191
MIN_PYTHON_VERSION = LooseVersion('{major}.{minor}'.format(major=MIN_PYTHON_MAJOR_VERSION,
192192
minor=MIN_PYTHON_MINOR_VERSION))
193193
PY2_ERROR_TEXT = (

0 commit comments

Comments
 (0)