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

kivy / python-for-android / 9022488340

09 May 2024 07:28PM UTC coverage: 59.119% (+0.2%) from 58.893%
9022488340

push

github

web-flow
recipe: introduce `PyProjectRecipe` and `MesonRecipe` (to update `pandas`, `numpy` and other recipes) (#3007)

1044 of 2353 branches covered (44.37%)

Branch coverage included in aggregate %.

75 of 167 new or added lines in 9 files covered. (44.91%)

5 existing lines in 2 files now uncovered.

4820 of 7566 relevant lines covered (63.71%)

2.54 hits per line

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

43.59
/pythonforandroid/recipes/numpy/__init__.py
1
from pythonforandroid.recipe import Recipe, MesonRecipe
4✔
2
from pythonforandroid.logger import error
4✔
3
from os.path import join
4✔
4
import shutil
4✔
5

6
NUMPY_NDK_MESSAGE = "In order to build numpy, you must set minimum ndk api (minapi) to `24`.\n"
4✔
7

8

9
class NumpyRecipe(MesonRecipe):
4✔
10
    version = 'v1.26.5'
4✔
11
    url = 'git+https://github.com/numpy/numpy'
4✔
12
    hostpython_prerequisites = ["Cython>=3.0.6"]  # meson does not detects venv's cython
4✔
13
    extra_build_args = ['-Csetup-args=-Dblas=none', '-Csetup-args=-Dlapack=none']
4✔
14
    need_stl_shared = True
4✔
15

16
    def get_recipe_meson_options(self, arch):
4✔
NEW
17
        options = super().get_recipe_meson_options(arch)
×
18
        # Custom python is required, so that meson
19
        # gets libs and config files properly
NEW
20
        options["binaries"]["python"] = self.ctx.python_recipe.python_exe
×
NEW
21
        options["binaries"]["python3"] = self.ctx.python_recipe.python_exe
×
NEW
22
        options["properties"]["longdouble_format"] = "IEEE_DOUBLE_LE" if arch.arch in ["armeabi-v7a", "x86"] else "IEEE_QUAD_LE"
×
NEW
23
        return options
×
24

25
    def get_recipe_env(self, arch, **kwargs):
4✔
NEW
26
        env = super().get_recipe_env(arch, **kwargs)
×
27

28
        # _PYTHON_HOST_PLATFORM declares that we're cross-compiling
29
        # and avoids issues when building on macOS for Android targets.
30
        env["_PYTHON_HOST_PLATFORM"] = arch.command_prefix
×
31

32
        # NPY_DISABLE_SVML=1 allows numpy to build for non-AVX512 CPUs
33
        # See: https://github.com/numpy/numpy/issues/21196
34
        env["NPY_DISABLE_SVML"] = "1"
×
NEW
35
        env["TARGET_PYTHON_EXE"] = join(Recipe.get_recipe(
×
36
                "python3", self.ctx).get_build_dir(arch.arch), "android-build", "python")
UNCOV
37
        return env
×
38

39
    def download_if_necessary(self):
4✔
40
        # NumPy requires complex math functions which were added in api 24
NEW
41
        if self.ctx.ndk_api < 24:
×
NEW
42
            error(NUMPY_NDK_MESSAGE)
×
NEW
43
            exit(1)
×
NEW
44
        super().download_if_necessary()
×
45

46
    def build_arch(self, arch):
4✔
UNCOV
47
        super().build_arch(arch)
×
NEW
48
        self.restore_hostpython_prerequisites(["cython"])
×
49

50
    def get_hostrecipe_env(self, arch):
4✔
51
        env = super().get_hostrecipe_env(arch)
×
52
        env['RANLIB'] = shutil.which('ranlib')
×
NEW
53
        env["LDFLAGS"] += " -lm"
×
UNCOV
54
        return env
×
55

56

57
recipe = NumpyRecipe()
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

© 2025 Coveralls, Inc