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

kivy / python-for-android / 22259302242

21 Feb 2026 03:24PM UTC coverage: 63.887% (+4.7%) from 59.214%
22259302242

Pull #3198

github

web-flow
Merge 758a52847 into 1fc026943
Pull Request #3198: Bump SDL3 (`3.4.2`) and SDL3_image (`3.4.0`) to the latest stable releases.

1823 of 3111 branches covered (58.6%)

Branch coverage included in aggregate %.

3 of 3 new or added lines in 2 files covered. (100.0%)

788 existing lines in 24 files now uncovered.

5287 of 8018 relevant lines covered (65.94%)

5.26 hits per line

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

97.14
/pythonforandroid/recipes/openssl/__init__.py
1
from os.path import join
8✔
2
from multiprocessing import cpu_count
8✔
3

4
from pythonforandroid.recipe import Recipe
8✔
5
from pythonforandroid.util import current_directory
8✔
6
from pythonforandroid.logger import shprint
8✔
7
import sh
8✔
8

9

10
class OpenSSLRecipe(Recipe):
8✔
11
    '''
12
    The OpenSSL libraries for python-for-android. This recipe will generate the
13
    following libraries as shared libraries (*.so):
14

15
        - crypto
16
        - ssl
17

18
    The generated openssl libraries are versioned, where the version is the
19
    recipe attribute :attr:`version` e.g.: ``libcrypto1.1.so``,
20
    ``libssl1.1.so``...so...to link your recipe with the openssl libs,
21
    remember to add the version at the end, e.g.:
22
    ``-lcrypto1.1 -lssl1.1``. Or better, you could do it dynamically
23
    using the methods: :meth:`include_flags`, :meth:`link_dirs_flags` and
24
    :meth:`link_libs_flags`.
25

26
    .. warning:: This recipe is very sensitive because is used for our core
27
        recipes, the python recipes. The used API should match with the one
28
        used in our python build, otherwise we will be unable to build the
29
        _ssl.so python module.
30

31
    .. versionchanged:: 0.6.0
32

33
        - The gcc compiler has been deprecated in favour of clang and libraries
34
          updated to version 1.1.1 (LTS - supported until 11th September 2023)
35
        - Added two new methods to make easier to link with openssl:
36
          :meth:`include_flags` and :meth:`link_flags`
37
        - subclassed versioned_url
38
        - Adapted method :meth:`select_build_arch` to API 21+
39
        - Add ability to build a legacy version of the openssl libs when using
40
          python2legacy or python3crystax.
41

42
    .. versionchanged:: 2019.06.06.1.dev0
43

44
        - Removed legacy version of openssl libraries
45

46
    '''
47

48
    version = '3.3.1'
8✔
49
    url = 'https://www.openssl.org/source/openssl-{version}.tar.gz'
8✔
50

51
    built_libraries = {
8✔
52
        'libcrypto.so': '.',
53
        'libssl.so': '.',
54
    }
55

56
    def get_build_dir(self, arch):
8✔
57
        return join(
8✔
58
            self.get_build_container_dir(arch), self.name + self.version[0]
59
        )
60

61
    def include_flags(self, arch):
8✔
62
        '''Returns a string with the include folders'''
63
        openssl_includes = join(self.get_build_dir(arch.arch), 'include')
8✔
64
        return (' -I' + openssl_includes +
8✔
65
                ' -I' + join(openssl_includes, 'openssl'))
66

67
    def link_dirs_flags(self, arch):
8✔
68
        '''Returns a string with the appropriate `-L<lib directory>` to link
69
        with the openssl libs. This string is usually added to the environment
70
        variable `LDFLAGS`'''
71
        return ' -L' + self.get_build_dir(arch.arch)
8✔
72

73
    def link_libs_flags(self):
8✔
74
        '''Returns a string with the appropriate `-l<lib>` flags to link with
75
        the openssl libs. This string is usually added to the environment
76
        variable `LIBS`'''
77
        return ' -lcrypto -lssl'
8✔
78

79
    def link_flags(self, arch):
8✔
80
        '''Returns a string with the flags to link with the openssl libraries
81
        in the format: `-L<lib directory> -l<lib>`'''
82
        return self.link_dirs_flags(arch) + self.link_libs_flags()
8✔
83

84
    def get_recipe_env(self, arch=None):
8✔
85
        env = super().get_recipe_env(arch)
8✔
86
        env['OPENSSL_VERSION'] = self.version[0]
8✔
87
        env['CC'] = 'clang'
8✔
88
        env['ANDROID_NDK_ROOT'] = self.ctx.ndk_dir
8✔
89
        env["PATH"] = f"{self.ctx.ndk.llvm_bin_dir}:{env['PATH']}"
8✔
90
        env["CFLAGS"] += " -Wno-macro-redefined"
8✔
91
        env["MAKE"] = "make"
8✔
92
        return env
8✔
93

94
    def select_build_arch(self, arch):
8✔
95
        aname = arch.arch
8✔
96
        if 'arm64' in aname:
8✔
97
            return 'android-arm64'
8✔
98
        if 'v7a' in aname:
8✔
99
            return 'android-arm'
8✔
100
        if 'arm' in aname:
8✔
101
            return 'android'
8✔
102
        if 'x86_64' in aname:
8✔
103
            return 'android-x86_64'
8✔
104
        if 'x86' in aname:
8!
105
            return 'android-x86'
8✔
UNCOV
106
        return 'linux-armv4'
×
107

108
    def build_arch(self, arch):
8✔
109
        env = self.get_recipe_env(arch)
8✔
110
        with current_directory(self.get_build_dir(arch.arch)):
8✔
111
            # sh fails with code 255 trying to execute ./Configure
112
            # so instead we manually run perl passing in Configure
113
            perl = sh.Command('perl')
8✔
114
            buildarch = self.select_build_arch(arch)
8✔
115
            config_args = [
8✔
116
                'shared',
117
                'no-dso',
118
                'no-asm',
119
                'no-tests',
120
                buildarch,
121
                '-D__ANDROID_API__={}'.format(self.ctx.ndk_api),
122
            ]
123
            shprint(perl, 'Configure', *config_args, _env=env)
8✔
124
            shprint(sh.make, '-j', str(cpu_count()), _env=env)
8✔
125

126

127
recipe = OpenSSLRecipe()
8✔
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