|
1 | | -from __future__ import print_function |
2 | | - |
3 | 1 | from os.path import ( |
4 | 2 | abspath, join, realpath, dirname, expanduser, exists, |
5 | 3 | split, isdir |
@@ -79,7 +77,7 @@ def get_available_apis(sdk_dir): |
79 | 77 | return apis |
80 | 78 |
|
81 | 79 |
|
82 | | -class Context(object): |
| 80 | +class Context: |
83 | 81 | '''A build context. If anything will be built, an instance this class |
84 | 82 | will be instantiated and used to hold all the build state.''' |
85 | 83 |
|
@@ -132,34 +130,33 @@ def templates_dir(self): |
132 | 130 | @property |
133 | 131 | def libs_dir(self): |
134 | 132 | # Was previously hardcoded as self.build_dir/libs |
135 | | - dir = join(self.build_dir, 'libs_collections', |
136 | | - self.bootstrap.distribution.name) |
137 | | - ensure_dir(dir) |
138 | | - return dir |
| 133 | + directory = join(self.build_dir, 'libs_collections', |
| 134 | + self.bootstrap.distribution.name) |
| 135 | + ensure_dir(directory) |
| 136 | + return directory |
139 | 137 |
|
140 | 138 | @property |
141 | 139 | def javaclass_dir(self): |
142 | 140 | # Was previously hardcoded as self.build_dir/java |
143 | | - dir = join(self.build_dir, 'javaclasses', |
144 | | - self.bootstrap.distribution.name) |
145 | | - ensure_dir(dir) |
146 | | - return dir |
| 141 | + directory = join(self.build_dir, 'javaclasses', |
| 142 | + self.bootstrap.distribution.name) |
| 143 | + ensure_dir(directory) |
| 144 | + return directory |
147 | 145 |
|
148 | 146 | @property |
149 | 147 | def aars_dir(self): |
150 | | - dir = join(self.build_dir, 'aars', self.bootstrap.distribution.name) |
151 | | - ensure_dir(dir) |
152 | | - return dir |
| 148 | + directory = join(self.build_dir, 'aars', self.bootstrap.distribution.name) |
| 149 | + ensure_dir(directory) |
| 150 | + return directory |
153 | 151 |
|
154 | 152 | @property |
155 | 153 | def python_installs_dir(self): |
156 | | - dir = join(self.build_dir, 'python-installs') |
157 | | - ensure_dir(dir) |
158 | | - return dir |
| 154 | + directory = join(self.build_dir, 'python-installs') |
| 155 | + ensure_dir(directory) |
| 156 | + return directory |
159 | 157 |
|
160 | 158 | def get_python_install_dir(self): |
161 | | - dir = join(self.python_installs_dir, self.bootstrap.distribution.name) |
162 | | - return dir |
| 159 | + return join(self.python_installs_dir, self.bootstrap.distribution.name) |
163 | 160 |
|
164 | 161 | def setup_dirs(self, storage_dir): |
165 | 162 | '''Calculates all the storage and build dirs, and makes sure |
@@ -264,7 +261,7 @@ def prepare_build_environment(self, |
264 | 261 | possible_dirs = glob.glob(expanduser(join( |
265 | 262 | '~', '.buildozer', 'android', 'platform', 'android-sdk-*'))) |
266 | 263 | possible_dirs = [d for d in possible_dirs if not |
267 | | - (d.endswith('.bz2') or d.endswith('.gz'))] |
| 264 | + d.endswith(('.bz2', '.gz'))] |
268 | 265 | if possible_dirs: |
269 | 266 | info('Found possible SDK dirs in buildozer dir: {}'.format( |
270 | 267 | ', '.join([d.split(os.sep)[-1] for d in possible_dirs]))) |
@@ -427,15 +424,13 @@ def prepare_build_environment(self, |
427 | 424 | for executable in ("pkg-config", "autoconf", "automake", "libtoolize", |
428 | 425 | "tar", "bzip2", "unzip", "make", "gcc", "g++"): |
429 | 426 | if not sh.which(executable): |
430 | | - warning("Missing executable: {} is not installed".format( |
431 | | - executable)) |
| 427 | + warning(f"Missing executable: {executable} is not installed") |
432 | 428 |
|
433 | 429 | if not ok: |
434 | 430 | raise BuildInterruptingException( |
435 | 431 | 'python-for-android cannot continue due to the missing executables above') |
436 | 432 |
|
437 | 433 | def __init__(self): |
438 | | - super().__init__() |
439 | 434 | self.include_dirs = [] |
440 | 435 |
|
441 | 436 | self._build_env_prepared = False |
@@ -605,23 +600,16 @@ def build_recipes(build_order, python_modules, ctx, project_dir, |
605 | 600 | ignore_setup_py=ignore_project_setup_py |
606 | 601 | ) |
607 | 602 |
|
608 | | - return |
609 | | - |
610 | 603 |
|
611 | 604 | def project_has_setup_py(project_dir): |
612 | | - if project_dir is not None and \ |
613 | | - (os.path.exists(os.path.join(project_dir, |
614 | | - "setup.py")) or |
615 | | - os.path.exists(os.path.join(project_dir, |
616 | | - "pyproject.toml")) |
617 | | - ): |
618 | | - return True |
619 | | - return False |
| 605 | + return (project_dir is not None and |
| 606 | + (exists(join(project_dir, "setup.py")) or |
| 607 | + exists(join(project_dir, "pyproject.toml")) |
| 608 | + )) |
620 | 609 |
|
621 | 610 |
|
622 | 611 | def run_setuppy_install(ctx, project_dir, env=None): |
623 | | - if env is None: |
624 | | - env = dict() |
| 612 | + env = env or {} |
625 | 613 |
|
626 | 614 | with current_directory(project_dir): |
627 | 615 | info('got setup.py or similar, running project install. ' + |
@@ -1076,5 +1064,4 @@ def copylibs_function(soname, objs_paths, extra_link_dirs=[], env=None): |
1076 | 1064 | '\n\t'.join(needed_libs)) |
1077 | 1065 |
|
1078 | 1066 | print('Copying libraries') |
1079 | | - for lib in sofiles: |
1080 | | - shprint(sh.cp, lib, dest) |
| 1067 | + shprint(sh.cp, *sofiles, dest) |
0 commit comments