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

kivy / python-for-android / 6215290912

17 Sep 2023 06:49PM UTC coverage: 59.095% (+1.4%) from 57.68%
6215290912

push

github

web-flow
Merge pull request #2891 from misl6/release-2023.09.16

* Update `cffi` recipe for Python 3.10 (#2800)

* Update __init__.py

version bump to 1.15.1

* Update disable-pkg-config.patch

adjust patch for 1.15.1

* Use build rather than pep517 for building (#2784)

pep517 has been renamed to pyproject-hooks, and as a consequence all of
the deprecated functionality has been removed. build now provides the
functionality required, and since we are only interested in the
metadata, we can leverage a helper function for that. I've also removed
all of the subprocess machinery for calling the wrapping function, since
it appears to not be as noisy as pep517.

* Bump actions/setup-python and actions/checkout versions, as old ones are deprecated (#2827)

* Removes `mysqldb` recipe as does not support Python 3 (#2828)

* Removes `Babel` recipe as it's not needed anymore. (#2826)

* Remove dateutil recipe, as it's not needed anymore (#2829)

* Optimize CI runs, by avoiding unnecessary rebuilds (#2833)

* Remove `pytz` recipe, as it's not needed anymore (#2830)

* `freetype` recipe: Changed the url to use https as http doesn't work (#2846)

* Fix `vlc` recipe build (#2841)

* Correct sys_platform (#2852)

On Window, sys.platform = "win32".

I think "nt" is a reference to os.name.

* Fix code string - quickstart.rst

* Bump `kivy` version to `2.2.1` (#2855)

* Use a pinned version of `Cython` for now, as most of the recipes are incompatible with `Cython==3.x.x` (#2862)

* Automatically generate required pre-requisites (#2858)

`get_required_prerequisites()` maintains a list of Prerequisites required by each platform.

But that same information is already stored in each Prerequisite class.

Rather than rather than maintaining two lists which might become inconsistent, auto-generate one.

* Use `platform.uname` instead of `os.uname` (#2857)

Advantages:

- Works cross platform, not just Unix.
- Is a namedtuple, ... (continued)

944 of 2241 branches covered (0.0%)

Branch coverage included in aggregate %.

174 of 272 new or added lines in 32 files covered. (63.97%)

9 existing lines in 5 files now uncovered.

4725 of 7352 relevant lines covered (64.27%)

2.56 hits per line

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

93.62
/pythonforandroid/util.py
1
import contextlib
4✔
2
from fnmatch import fnmatch
4✔
3
import logging
4✔
4
from os.path import exists, join
4✔
5
from os import getcwd, chdir, makedirs, walk
4✔
6
from pathlib import Path
4✔
7
from platform import uname
4✔
8
import shutil
4✔
9
from tempfile import mkdtemp
4✔
10

11
from pythonforandroid.logger import (logger, Err_Fore, error, info)
4✔
12

13
LOGGER = logging.getLogger("p4a.util")
4✔
14

15
build_platform = "{system}-{machine}".format(
4✔
16
    system=uname().system, machine=uname().machine
17
).lower()
18
"""the build platform in the format `system-machine`. We use
2✔
19
this string to define the right build system when compiling some recipes or
20
to get the right path for clang compiler"""
21

22

23
@contextlib.contextmanager
4✔
24
def current_directory(new_dir):
4✔
25
    cur_dir = getcwd()
4✔
26
    logger.info(''.join((Err_Fore.CYAN, '-> directory context ', new_dir,
4✔
27
                         Err_Fore.RESET)))
28
    chdir(new_dir)
4✔
29
    yield
4✔
30
    logger.info(''.join((Err_Fore.CYAN, '<- directory context ', cur_dir,
4✔
31
                         Err_Fore.RESET)))
32
    chdir(cur_dir)
4✔
33

34

35
@contextlib.contextmanager
4✔
36
def temp_directory():
4✔
37
    temp_dir = mkdtemp()
4✔
38
    try:
4✔
39
        logger.debug(''.join((Err_Fore.CYAN, ' + temp directory used ',
4✔
40
                              temp_dir, Err_Fore.RESET)))
41
        yield temp_dir
4✔
42
    finally:
43
        shutil.rmtree(temp_dir)
4✔
44
        logger.debug(''.join((Err_Fore.CYAN, ' - temp directory deleted ',
4✔
45
                              temp_dir, Err_Fore.RESET)))
46

47

48
def walk_valid_filens(base_dir, invalid_dir_names, invalid_file_patterns):
4✔
49
    """Recursively walks all the files and directories in ``dirn``,
50
    ignoring directories that match any pattern in ``invalid_dirns``
51
    and files that patch any pattern in ``invalid_filens``.
52

53
    ``invalid_dirns`` and ``invalid_filens`` should both be lists of
54
    strings to match. ``invalid_dir_patterns`` expects a list of
55
    invalid directory names, while ``invalid_file_patterns`` expects a
56
    list of glob patterns compared against the full filepath.
57

58
    File and directory paths are evaluated as full paths relative to ``dirn``.
59

60
    """
61

62
    for dirn, subdirs, filens in walk(base_dir):
4✔
63

64
        # Remove invalid subdirs so that they will not be walked
65
        for i in reversed(range(len(subdirs))):
4✔
66
            subdir = subdirs[i]
4✔
67
            if subdir in invalid_dir_names:
4✔
68
                subdirs.pop(i)
4✔
69

70
        for filen in filens:
4✔
71
            for pattern in invalid_file_patterns:
4✔
72
                if fnmatch(filen, pattern):
4✔
73
                    break
4✔
74
            else:
75
                yield join(dirn, filen)
4✔
76

77

78
def load_source(module, filename):
4✔
79
    # Python 3.5+
80
    import importlib.util
4✔
81
    if hasattr(importlib.util, 'module_from_spec'):
4!
82
        spec = importlib.util.spec_from_file_location(module, filename)
4✔
83
        mod = importlib.util.module_from_spec(spec)
4✔
84
        spec.loader.exec_module(mod)
4✔
85
        return mod
4✔
86
    else:
87
        # Python 3.3 and 3.4:
88
        from importlib.machinery import SourceFileLoader
×
89
        return SourceFileLoader(module, filename).load_module()
×
90

91

92
class BuildInterruptingException(Exception):
4✔
93
    def __init__(self, message, instructions=None):
4✔
94
        super().__init__(message, instructions)
4✔
95
        self.message = message
4✔
96
        self.instructions = instructions
4✔
97

98

99
def handle_build_exception(exception):
4✔
100
    """
101
    Handles a raised BuildInterruptingException by printing its error
102
    message and associated instructions, if any, then exiting.
103
    """
104
    error('Build failed: {}'.format(exception.message))
4✔
105
    if exception.instructions is not None:
4!
106
        info('Instructions: {}'.format(exception.instructions))
4✔
107
    exit(1)
4✔
108

109

110
def rmdir(dn, ignore_errors=False):
4✔
111
    if not exists(dn):
4!
NEW
112
        return
×
113
    LOGGER.debug("Remove directory and subdirectory {}".format(dn))
4✔
114
    shutil.rmtree(dn, ignore_errors)
4✔
115

116

117
def ensure_dir(dn):
4✔
118
    if exists(dn):
4✔
119
        return
4✔
120
    LOGGER.debug("Create directory {0}".format(dn))
4✔
121
    makedirs(dn)
4✔
122

123

124
def move(source, destination):
4✔
125
    LOGGER.debug("Moving {} to {}".format(source, destination))
4✔
126
    shutil.move(source, destination)
4✔
127

128

129
def touch(filename):
4✔
130
    Path(filename).touch()
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