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

kivy / python-for-android / 17089680151

20 Aug 2025 05:44AM UTC coverage: 59.287% (+0.07%) from 59.214%
17089680151

Pull #3180

github

web-flow
Merge fc5223de3 into 5330267b5
Pull Request #3180: `python`: add `3.13` support

1068 of 2403 branches covered (44.44%)

Branch coverage included in aggregate %.

119 of 161 new or added lines in 17 files covered. (73.91%)

12 existing lines in 5 files now uncovered.

5003 of 7837 relevant lines covered (63.84%)

2.54 hits per line

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

24.14
/pythonforandroid/recipes/android/__init__.py
1
from pythonforandroid.recipe import PyProjectRecipe, IncludedFilesBehaviour
4✔
2
from pythonforandroid.util import current_directory
4✔
3
from pythonforandroid import logger
4✔
4

5
from os.path import join
4✔
6

7

8
class AndroidRecipe(IncludedFilesBehaviour, PyProjectRecipe):
4✔
9
    # name = 'android'
10
    version = None
4✔
11
    url = None
4✔
12

13
    src_filename = 'src'
4✔
14

15
    depends = [('sdl3', 'sdl2', 'genericndkbuild'), 'pyjnius']
4✔
16
    hostpython_prerequisites = ["cython"]
4✔
17

18
    config_env = {}
4✔
19

20
    def get_recipe_env(self, arch, **kwargs):
4✔
NEW
21
        env = super().get_recipe_env(arch, **kwargs)
×
22
        env.update(self.config_env)
×
23
        return env
×
24

25
    def prebuild_arch(self, arch):
4✔
26
        super().prebuild_arch(arch)
×
27
        ctx_bootstrap = self.ctx.bootstrap.name
×
28

29
        # define macros for Cython, C, Python
30
        tpxi = 'DEF {} = {}\n'
×
31
        th = '#define {} {}\n'
×
32
        tpy = '{} = {}\n'
×
33

34
        # make sure bootstrap name is in unicode
35
        if isinstance(ctx_bootstrap, bytes):
×
36
            ctx_bootstrap = ctx_bootstrap.decode('utf-8')
×
37
        bootstrap = bootstrap_name = ctx_bootstrap
×
38
        if bootstrap_name in ["sdl2", "sdl3", "webview", "service_only", "service_library", "qt"]:
×
39
            java_ns = u'org.kivy.android'
×
40
            jni_ns = u'org/kivy/android'
×
41
        else:
42
            logger.error((
×
43
                'unsupported bootstrap for android recipe: {}'
44
                ''.format(bootstrap_name)
45
            ))
46
            exit(1)
×
47

NEW
48
        libs_dir = self.ctx.get_libs_dir(arch.arch) + ":" + join(self.ctx.bootstrap.build_dir, 'obj', 'local', arch.arch)
×
49

UNCOV
50
        config = {
×
51
            'BOOTSTRAP': bootstrap,
52
            'IS_SDL2': int(bootstrap_name == "sdl2"),
53
            'IS_SDL3': int(bootstrap_name == "sdl3"),
54
            'PY2': 0,
55
            'ANDROID_LIBS_DIR': libs_dir,
56
            'JAVA_NAMESPACE': java_ns,
57
            'JNI_NAMESPACE': jni_ns,
58
            'ACTIVITY_CLASS_NAME': self.ctx.activity_class_name,
59
            'ACTIVITY_CLASS_NAMESPACE': self.ctx.activity_class_name.replace('.', '/'),
60
            'SERVICE_CLASS_NAME': self.ctx.service_class_name,
61
        }
62

63
        # create config files for Cython, C and Python
64
        with (
×
65
                current_directory(self.get_build_dir(arch.arch))), (
66
                open(join('android', 'config.pxi'), 'w')) as fpxi, (
67
                open(join('android', 'config.h'), 'w')) as fh, (
68
                open(join('android', 'config.py'), 'w')) as fpy:
69

70
            for key, value in config.items():
×
71
                fpxi.write(tpxi.format(key, repr(value)))
×
72
                fpy.write(tpy.format(key, repr(value)))
×
73

74
                fh.write(th.format(
×
75
                    key,
76
                    value if isinstance(value, int) else '"{}"'.format(value)
77
                ))
78
                self.config_env[key] = str(value)
×
79

80
            if bootstrap_name == "sdl2":
×
81
                fh.write('JNIEnv *SDL_AndroidGetJNIEnv(void);\n')
×
82
                fh.write(
×
83
                    '#define SDL_ANDROID_GetJNIEnv SDL_AndroidGetJNIEnv\n'
84
                )
85
            elif bootstrap_name == "sdl3":
×
86
                fh.write('JNIEnv *SDL_GetAndroidJNIEnv(void);\n')
×
87
                fh.write(
×
88
                    '#define SDL_ANDROID_GetJNIEnv SDL_GetAndroidJNIEnv\n'
89
                )
90
            else:
91
                fh.write('JNIEnv *WebView_AndroidGetJNIEnv(void);\n')
×
92
                fh.write(
×
93
                    '#define SDL_ANDROID_GetJNIEnv WebView_AndroidGetJNIEnv\n'
94
                )
95

96

97
recipe = AndroidRecipe()
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