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

kivy / python-for-android / 7239023125

17 Dec 2023 02:11PM UTC coverage: 59.041% (-0.05%) from 59.09%
7239023125

push

github

web-flow
Update sdl2 deps to reflect the same targeted in kivy/kivy (#2927)

* Update sdl2 deps to reflect the same targeted in kivy/kivy

* Update md5 sum

* Create new patch and set new include dir for sdl_image

* Set pygame as broken recipe

* sdl_image 2.8.0 has been released

941 of 2245 branches covered (0.0%)

Branch coverage included in aggregate %.

6 of 12 new or added lines in 6 files covered. (50.0%)

3 existing lines in 3 files now uncovered.

4734 of 7367 relevant lines covered (64.26%)

2.56 hits per line

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

35.19
/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✔
12
    with current_directory(join(recipe.get_build_dir(arch.arch), "kivy")):
×
13
        kivy_version = shprint(
×
14
            sh.Command(sys.executable),
15
            "-c",
16
            "import _version; print(_version.__version__)",
17
        )
18

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.2.1'
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', 'chardet', 'idna', 'requests', 'urllib3']
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'
×
68
            sdl2_mixer_recipe = self.get_recipe('sdl2_mixer', self.ctx)
×
NEW
69
            sdl2_image_recipe = self.get_recipe('sdl2_image', self.ctx)
×
UNCOV
70
            env['KIVY_SDL2_PATH'] = ':'.join([
×
71
                join(self.ctx.bootstrap.build_dir, 'jni', 'SDL', 'include'),
72
                *sdl2_image_recipe.get_include_dirs(arch),
73
                *sdl2_mixer_recipe.get_include_dirs(arch),
74
                join(self.ctx.bootstrap.build_dir, 'jni', 'SDL2_ttf'),
75
            ])
76

77
        return env
×
78

79

80
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