Skip to content

Commit a963112

Browse files
committed
Improved code style per review comments
1 parent dbf9815 commit a963112

File tree

5 files changed

+17
-26
lines changed

5 files changed

+17
-26
lines changed

pythonforandroid/bootstraps/sdl2/build/build.py

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,9 @@ def make_package(args):
240240

241241
# Package up the private data (public not supported).
242242
tar_dirs = [args.private]
243-
if exists('private'):
244-
tar_dirs.append('private')
245-
if exists('crystax_python'):
246-
tar_dirs.append('crystax_python')
247-
if exists('_python_bundle'):
248-
tar_dirs.append('_python_bundle')
243+
for python_bundle_dir in ('private', 'crystax_python', '_python_bundle'):
244+
if exists(python_bundle_dir):
245+
tar_dirs.append(python_bundle_Dir)
249246

250247
if args.private:
251248
make_tar('src/main/assets/private.mp3', tar_dirs, args.ignore_path)
@@ -413,14 +410,14 @@ def make_package(args):
413410
def parse_args(args=None):
414411
global BLACKLIST_PATTERNS, WHITELIST_PATTERNS, PYTHON
415412

416-
# Get the default minsdk, equal to the NDK API that this dist it built against
413+
# Get the default minsdk, equal to the NDK API that this dist is built against
417414
with open('dist_info.json', 'r') as fileh:
418415
info = json.load(fileh)
419416
if 'ndk_api' not in info:
420-
print('Failed to read ndk_api from dist info')
421-
default_android_api = 12 # The old default before ndk_api was introduced
417+
print('WARNING: Failed to read ndk_api from dist info, defaulting to 12')
418+
default_min_api = 12 # The old default before ndk_api was introduced
422419
else:
423-
default_android_api = info['ndk_api']
420+
default_min_api = info['ndk_api']
424421
ndk_api = info['ndk_api']
425422

426423
import argparse
@@ -504,9 +501,9 @@ def parse_args(args=None):
504501
ap.add_argument('--sdk', dest='sdk_version', default=-1,
505502
type=int, help=('Deprecated argument, does nothing'))
506503
ap.add_argument('--minsdk', dest='min_sdk_version',
507-
default=default_android_api, type=int,
504+
default=default_min_api, type=int,
508505
help=('Minimum Android SDK version that the app supports. '
509-
'Defaults to {}.'.format(default_android_api)))
506+
'Defaults to {}.'.format(default_min_api)))
510507
ap.add_argument('--allow-minsdk-ndkapi-mismatch', default=False,
511508
action='store_true',
512509
help=('Allow the --minsdk argument to be different from '

pythonforandroid/bootstraps/sdl2/build/jni/src/start.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,19 +123,18 @@ int main(int argc, char *argv[]) {
123123
snprintf(paths, 256,
124124
"%s/stdlib.zip:%s/modules",
125125
crystax_python_dir, crystax_python_dir);
126-
LOGP("calculated paths to be...");
127-
LOGP(paths);
128126
}
129127

130128
if (dir_exists(python_bundle_dir)) {
131129
LOGP("_python_bundle dir exists");
132130
snprintf(paths, 256,
133131
"%s/stdlib.zip:%s/modules",
134132
python_bundle_dir, python_bundle_dir);
135-
LOGP("calculated paths to be...");
136-
LOGP(paths);
137133
}
138134

135+
LOGP("calculated paths to be...");
136+
LOGP(paths);
137+
139138

140139
#if PY_MAJOR_VERSION >= 3
141140
wchar_t *wchar_paths = Py_DecodeLocale(paths, NULL);
@@ -148,7 +147,10 @@ int main(int argc, char *argv[]) {
148147

149148
LOGP("set wchar paths...");
150149
} else {
151-
LOGP("crystax_python does not exist");
150+
// We do not expect to see crystax_python any more, so no point
151+
// reminding the user about it. If it does exist, we'll have
152+
// logged it earlier.
153+
LOGP("_python_bundle does not exist");
152154
}
153155

154156
Py_Initialize();

pythonforandroid/recipes/hostpython3/__init__.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,25 +30,19 @@ def build_arch(self, arch):
3030

3131
if not exists(join(build_dir, 'python')):
3232
with current_directory(recipe_build_dir):
33-
env = {} # The command line environment we will use
34-
35-
3633
# Configure the build
3734
with current_directory(build_dir):
3835
if not exists('config.status'):
3936
shprint(sh.Command(join(recipe_build_dir, 'configure')))
4037

4138
# Create the Setup file. This copying from Setup.dist
4239
# seems to be the normal and expected procedure.
43-
assert exists(join(build_dir, 'Modules')), (
44-
'Expected dir {} does not exist'.format(join(build_dir, 'Modules')))
4540
shprint(sh.cp, join('Modules', 'Setup.dist'), join(build_dir, 'Modules', 'Setup'))
4641

4742
result = shprint(sh.make, '-C', build_dir)
4843
else:
4944
info('Skipping hostpython3 build as it has already been completed')
5045

5146
self.ctx.hostpython = join(build_dir, 'python')
52-
self.ctx.hostpgen = '/usr/bin/false' # is this actually used for anything?
5347

5448
recipe = Hostpython3Recipe()

pythonforandroid/recipes/hostpython3crystax/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ def build_arch(self, arch):
2727
Creates expected build and symlinks system Python version.
2828
"""
2929
self.ctx.hostpython = '/usr/bin/false'
30-
self.ctx.hostpgen = '/usr/bin/false'
3130
# creates the sub buildir (used by other recipes)
3231
# https://github.com/kivy/python-for-android/issues/1154
3332
sub_build_dir = join(self.get_build_dir(), 'build')

pythonforandroid/recipes/python2/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,7 @@ def create_python_bundle(self, dirn, arch):
209209
# To quote the original distribute.sh, 'well...'
210210
shprint(sh.rm, '-rf', 'lib2to3')
211211
shprint(sh.rm, '-rf', 'idlelib')
212-
for filename in glob.glob('config/libpython*.a'):
213-
shprint(sh.rm, '-f', filename)
212+
shprint(sh.rm, '-f', *glob.glob('config/libpython*.a'))
214213
shprint(sh.rm, '-rf', 'config/python.o')
215214

216215
return site_packages_dir

0 commit comments

Comments
 (0)