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

kivy / python-for-android / 7629126644

23 Jan 2024 04:54PM CUT coverage: 59.066% (+0.04%) from 59.022%
7629126644

push

github

web-flow
Merge pull request #2959 from kivy/release-2024.01.21

Release 2024.01.21

950 of 2263 branches covered (0.0%)

Branch coverage included in aggregate %.

4767 of 7416 relevant lines covered (64.28%)

2.56 hits per line

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

26.0
/pythonforandroid/recipes/matplotlib/__init__.py
1
from pythonforandroid.recipe import CppCompiledComponentsPythonRecipe
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(CppCompiledComponentsPythonRecipe):
4✔
9

10
    version = '3.5.2'
4✔
11
    url = 'https://github.com/matplotlib/matplotlib/archive/v{version}.zip'
4✔
12

13
    depends = ['kiwisolver', 'numpy', 'pillow', 'setuptools', 'freetype']
4✔
14

15
    python_depends = ['cycler', 'fonttools', 'packaging', 'pyparsing', 'python-dateutil']
4✔
16

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

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

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

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

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

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

65
    def get_recipe_env(self, arch=None, with_flags_in_cc=True):
4✔
66
        env = super().get_recipe_env(arch, with_flags_in_cc)
×
67

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

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

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

93

94
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