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

kivy / python-for-android / 3770732673

pending completion
3770732673

push

github

GitHub
Merge pull request #2718 from kivy/release-2022.12.20

877 of 2011 branches covered (43.61%)

Branch coverage included in aggregate %.

38 of 86 new or added lines in 16 files covered. (44.19%)

4515 of 6886 relevant lines covered (65.57%)

2.59 hits per line

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

35.85
/pythonforandroid/recipes/kivy/__init__.py
1
import glob
4✔
2
from os.path import basename, exists, join
4✔
3
import sys
4✔
4
import packaging.version
4✔
5

6
import sh
4✔
7
from pythonforandroid.recipe import CythonRecipe
4✔
8
from pythonforandroid.toolchain import current_directory, shprint
4✔
9

10

11
def is_kivy_affected_by_deadlock_issue(recipe=None, arch=None):
4✔
NEW
12
    with current_directory(join(recipe.get_build_dir(arch.arch), "kivy")):
×
NEW
13
        kivy_version = shprint(
×
14
            sh.Command(sys.executable),
15
            "-c",
16
            "import _version; print(_version.__version__)",
17
        )
18

NEW
19
        return packaging.version.parse(
×
20
            str(kivy_version)
21
        ) < packaging.version.Version("2.2.0.dev0")
22

23

24
class KivyRecipe(CythonRecipe):
4✔
25
    version = '2.1.0'
4✔
26
    url = 'https://github.com/kivy/kivy/archive/{version}.zip'
4✔
27
    name = 'kivy'
4✔
28

29
    depends = ['sdl2', 'pyjnius', 'setuptools']
4✔
30
    python_depends = ['certifi']
4✔
31

32
    # sdl-gl-swapwindow-nogil.patch is needed to avoid a deadlock.
33
    # See: https://github.com/kivy/kivy/pull/8025
34
    # WARNING: Remove this patch when a new Kivy version is released.
35
    patches = [("sdl-gl-swapwindow-nogil.patch", is_kivy_affected_by_deadlock_issue)]
4✔
36

37
    def cythonize_build(self, env, build_dir='.'):
4✔
38
        super().cythonize_build(env, build_dir=build_dir)
×
39

40
        if not exists(join(build_dir, 'kivy', 'include')):
×
41
            return
×
42

43
        # If kivy is new enough to use the include dir, copy it
44
        # manually to the right location as we bypass this stage of
45
        # the build
46
        with current_directory(build_dir):
×
47
            build_libs_dirs = glob.glob(join('build', 'lib.*'))
×
48

49
            for dirn in build_libs_dirs:
×
50
                shprint(sh.cp, '-r', join('kivy', 'include'),
×
51
                        join(dirn, 'kivy'))
52

53
    def cythonize_file(self, env, build_dir, filename):
4✔
54
        # We can ignore a few files that aren't important to the
55
        # android build, and may not work on Android anyway
56
        do_not_cythonize = ['window_x11.pyx', ]
×
57
        if basename(filename) in do_not_cythonize:
×
58
            return
×
59
        super().cythonize_file(env, build_dir, filename)
×
60

61
    def get_recipe_env(self, arch):
4✔
62
        env = super().get_recipe_env(arch)
×
63
        # NDKPLATFORM is our switch for detecting Android platform, so can't be None
64
        env['NDKPLATFORM'] = "NOTNONE"
×
65
        if 'sdl2' in self.ctx.recipe_build_order:
×
66
            env['USE_SDL2'] = '1'
×
67
            env['KIVY_SPLIT_EXAMPLES'] = '1'
×
NEW
68
            sdl2_mixer_recipe = self.get_recipe('sdl2_mixer', self.ctx)
×
69
            env['KIVY_SDL2_PATH'] = ':'.join([
×
70
                join(self.ctx.bootstrap.build_dir, 'jni', 'SDL', 'include'),
71
                join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_image'),
72
                *sdl2_mixer_recipe.get_include_dirs(arch),
73
                join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_ttf'),
74
            ])
75

76
        return env
×
77

78

79
recipe = KivyRecipe()
4✔
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