• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

kivy / python-for-android / 18319816173

07 Oct 2025 04:45PM UTC coverage: 59.087% (-0.04%) from 59.122%
18319816173

Pull #3180

github

web-flow
Merge 4592ee3db into 3c5b66d67
Pull Request #3180: `python`: add `3.14` support

1069 of 2411 branches covered (44.34%)

Branch coverage included in aggregate %.

91 of 129 new or added lines in 6 files covered. (70.54%)

10 existing lines in 3 files now uncovered.

4988 of 7840 relevant lines covered (63.62%)

2.53 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

35.38
/pythonforandroid/patching.py
1
"""
2
    Helper functions for recipes.
3

4
    Recipes must supply a list of patches.
5

6
    Patches consist of a filename and an optional conditional, which is
7
    any function of the form:
8
        def patch_check(arch: string, recipe : Recipe) -> bool
9

10
    This library provides some helpful conditionals and mechanisms to
11
    join multiple conditionals.
12

13
    Example:
14
        patches = [
15
            ("linux_or_darwin_only.patch",
16
             check_any(is_linux, is_darwin),
17
            ("recent_android_API.patch",
18
             is_apt_gte(27)),
19
            ]
20
"""
21
from platform import uname
4✔
22
from packaging.version import Version
4✔
23

24

25
# Platform checks
26

27

28
def is_platform(platform):
4✔
29
    """
30
    Returns true if the host platform matches the parameter given.
31
    """
32

33
    def check(arch, recipe):
4✔
34
        return uname().system.lower() == platform.lower()
×
35

36
    return check
4✔
37

38

39
is_linux = is_platform("Linux")
4✔
40
is_darwin = is_platform("Darwin")
4✔
41
is_windows = is_platform("Windows")
4✔
42

43

44
def is_arch(xarch):
4✔
45
    """
46
    Returns true if the target architecture platform matches the parameter
47
    given.
48
    """
49

50
    def check(arch):
×
51
        return arch.arch == xarch
×
52

53
    return check
×
54

55

56
# Android API comparisons:
57
# Return true if the Android API level being targeted
58
# is equal (or >, >=, <, <= as appropriate) the given parameter
59

60

61
def is_api(apiver: int):
4✔
62
    def check(arch, recipe):
×
63
        return recipe.ctx.android_api == apiver
×
64

65
    return check
×
66

67

68
def is_api_gt(apiver: int):
4✔
69
    def check(arch, recipe):
×
70
        return recipe.ctx.android_api > apiver
×
71

72
    return check
×
73

74

75
def is_api_gte(apiver: int):
4✔
76
    def check(arch, recipe):
×
77
        return recipe.ctx.android_api >= apiver
×
78

79
    return check
×
80

81

82
def is_api_lt(apiver: int):
4✔
83
    def check(arch, recipe):
×
84
        return recipe.ctx.android_api < apiver
×
85

86
    return check
×
87

88

89
def is_api_lte(apiver: int):
4✔
90
    def check(arch, recipe):
×
91
        return recipe.ctx.android_api <= apiver
×
92

93
    return check
×
94

95

96
# Android API comparisons:
97

98

99
def is_ndk(ndk):
4✔
100
    """
101
    Return true if the Minimum Supported Android NDK level being targeted
102
    is equal the given parameter (which should be an AndroidNDK instance)
103
    """
104

105
    def check(arch, recipe):
×
106
        return recipe.ctx.ndk == ndk
×
107

108
    return check
×
109

110

111
# Recipe Version comparisons:
112
# These compare the Recipe's version with the provided string (or
113
# Packaging.Version).
114
#
115
# Warning: Both strings must conform to PEP 440 - e.g. "3.2.1" or "1.0rc1"
116

117

118
def is_version_gt(version):
4✔
119
    """Return true if the Recipe's version is greater"""
120

121
    def check(arch, recipe):
×
122
        return Version(recipe.version) > Version(version)
×
123

124
    return check
×
125

126

127
def is_version_lt(version):
4✔
128
    """Return true if the Recipe's version is less than"""
129

130
    def check(arch, recipe):
×
131
        return Version(recipe.version) < Version(version)
×
132

133
    return check
×
134

135

136
def version_starts_with(version_prefix):
4✔
UNCOV
137
    def check(arch, recipe):
×
138
        return recipe.version.startswith(version_prefix)
×
139

UNCOV
140
    return check
×
141

142

143
# Will Build
144

145

146
def will_build(recipe_name):
4✔
147
    """Return true if the recipe with this name is planned to be included in
148
    the distribution."""
149

150
    def check(arch, recipe):
4✔
151
        return recipe_name in recipe.ctx.recipe_build_order
×
152

153
    return check
4✔
154

155

156
# Conjunctions
157

158

159
def check_all(*patch_checks):
4✔
160
    """
161
    Given a collection of patch_checks as params, return if all returned true.
162
    """
163

164
    def check(arch, recipe):
×
165
        return all(patch_check(arch, recipe) for patch_check in patch_checks)
×
166

167
    return check
×
168

169

170
def check_any(*patch_checks):
4✔
171
    """
172
    Given a collection of patch_checks as params, return if any returned true.
173
    """
174

175
    def check(arch, recipe):
×
176
        return any(patch_check(arch, recipe) for patch_check in patch_checks)
×
177

178
    return check
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc