• 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

28.85
/pythonforandroid/recipes/matplotlib/__init__.py
1
from pythonforandroid.recipe import PyProjectRecipe
4✔
2
from pythonforandroid.util import ensure_dir
4✔
3

4
from os.path import join
4✔
5
import shutil
4✔
6

7

8
class MatplotlibRecipe(PyProjectRecipe):
4✔
9
    version = '3.8.4'
4✔
10
    url = 'https://github.com/matplotlib/matplotlib/archive/v{version}.zip'
4✔
11
    patches = ["skip_macos.patch"]
4✔
12
    depends = ['kiwisolver', 'numpy', 'pillow', 'setuptools', 'freetype']
4✔
13
    python_depends = ['cycler', 'fonttools', 'packaging', 'pyparsing', 'python-dateutil']
4✔
14
    need_stl_shared = True
4✔
15

16
    def generate_libraries_pc_files(self, arch):
4✔
17
        """
18
        Create *.pc files for libraries that `matplotib` depends on.
19

20
        Because, for unix platforms, the mpl install script uses `pkg-config`
21
        to detect libraries installed in non standard locations (our case...
22
        well...we don't even install the libraries...so we must trick a little
23
        the mlp install).
24
        """
25
        pkg_config_path = self.get_recipe_env(arch)['PKG_CONFIG_PATH']
×
26
        ensure_dir(pkg_config_path)
×
27

28
        lib_to_pc_file = {
×
29
            # `pkg-config` search for version freetype2.pc, our current
30
            # version for freetype, but we have our recipe named without
31
            # the version...so we add it in here for our pc file
32
            'freetype': 'freetype2.pc',
33
        }
34

35
        for lib_name in {'freetype'}:
×
36
            pc_template_file = join(
×
37
                self.get_recipe_dir(),
38
                f'lib{lib_name}.pc.template'
39
            )
40
            # read template file into buffer
41
            with open(pc_template_file) as template_file:
×
42
                text_buffer = template_file.read()
×
43
            # set the library absolute path and library version
44
            lib_recipe = self.get_recipe(lib_name, self.ctx)
×
45
            text_buffer = text_buffer.replace(
×
46
                'path_to_built', lib_recipe.get_build_dir(arch.arch),
47
            )
48
            text_buffer = text_buffer.replace(
×
49
                'library_version', lib_recipe.version,
50
            )
51

52
            # write the library pc file into our defined dir `PKG_CONFIG_PATH`
53
            pc_dest_file = join(pkg_config_path, lib_to_pc_file[lib_name])
×
54
            with open(pc_dest_file, 'w') as pc_file:
×
55
                pc_file.write(text_buffer)
×
56

57
    def prebuild_arch(self, arch):
4✔
58
        shutil.copyfile(
×
59
            join(self.get_recipe_dir(), "setup.cfg.template"),
60
            join(self.get_build_dir(arch), "mplsetup.cfg"),
61
        )
62
        self.generate_libraries_pc_files(arch)
×
63

64
    def get_recipe_env(self, arch, **kwargs):
4✔
NEW
65
        env = super().get_recipe_env(arch, **kwargs)
×
66

67
        # we make use of the same directory than `XDG_CACHE_HOME`, for our
68
        # custom library pc files, so we have all the install files that we
69
        # generate at the same place
70
        env['XDG_CACHE_HOME'] = join(self.get_build_dir(arch), 'p4a_files')
×
71
        env['PKG_CONFIG_PATH'] = env['XDG_CACHE_HOME']
×
72

73
        # creating proper *.pc files for our libraries does not seem enough to
74
        # success with our build (without depending on system development
75
        # libraries), but if we tell the compiler where to find our libraries
76
        # and includes, then the install success :)
77
        freetype = self.get_recipe('freetype', self.ctx)
×
78
        free_lib_dir = join(freetype.get_build_dir(arch.arch), 'objs', '.libs')
×
79
        free_inc_dir = join(freetype.get_build_dir(arch.arch), 'include')
×
80
        env['CFLAGS'] += f' -I{free_inc_dir}'
×
81
        env['LDFLAGS'] += f' -L{free_lib_dir}'
×
82

83
        # `freetype` could be built with `harfbuzz` support,
84
        # so we also include the necessary flags...just to be sure
85
        if 'harfbuzz' in self.ctx.recipe_build_order:
×
86
            harfbuzz = self.get_recipe('harfbuzz', self.ctx)
×
87
            harf_build = harfbuzz.get_build_dir(arch.arch)
×
88
            env['CFLAGS'] += f' -I{harf_build} -I{join(harf_build, "src")}'
×
89
            env['LDFLAGS'] += f' -L{join(harf_build, "src", ".libs")}'
×
90
        return env
×
91

92

93
recipe = MatplotlibRecipe()
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