From 7a515d0d49f9052f2a45e5826635bcc0d27c2b2b Mon Sep 17 00:00:00 2001 From: jayd Date: Fri, 25 Jan 2019 11:32:53 +0700 Subject: [PATCH 1/6] Fix strip failing (when arch is other than armeabi-v7a, e.g. x86) due to hardcoding --- pythonforandroid/bootstrap.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) mode change 100644 => 100755 pythonforandroid/bootstrap.py diff --git a/pythonforandroid/bootstrap.py b/pythonforandroid/bootstrap.py old mode 100644 new mode 100755 index 2304f281ff..85da077a33 --- a/pythonforandroid/bootstrap.py +++ b/pythonforandroid/bootstrap.py @@ -263,11 +263,11 @@ def strip_libraries(self, arch): info('Python was loaded from CrystaX, skipping strip') return env = arch.get_env() - strip = which('arm-linux-androideabi-strip', env['PATH']) + strip = env['STRIP'].split(' ')[0] if strip is None: warning('Can\'t find strip in PATH...') return - strip = sh.Command(strip) + strip = sh.Command(strip).bake('--strip-unneeded') libs_dir = join(self.dist_dir, '_python_bundle', '_python_bundle', 'modules') From a2e63c953bffbf299eceaa06d91f1832b522f7a4 Mon Sep 17 00:00:00 2001 From: jayd Date: Fri, 25 Jan 2019 11:50:10 +0700 Subject: [PATCH 2/6] Fix applying strip when the file name is '' --- pythonforandroid/bootstrap.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pythonforandroid/bootstrap.py b/pythonforandroid/bootstrap.py index 85da077a33..05dfdff01d 100755 --- a/pythonforandroid/bootstrap.py +++ b/pythonforandroid/bootstrap.py @@ -278,6 +278,8 @@ def strip_libraries(self, arch): logger.info('Stripping libraries in private dir') for filen in filens.split('\n'): + if not filen: + continue # skip the last '' try: strip(filen, _env=env) except sh.ErrorReturnCode_1: From 73d13ad4268281be458abdc496f933d19fc06280 Mon Sep 17 00:00:00 2001 From: jayd Date: Sat, 26 Jan 2019 22:08:42 +0700 Subject: [PATCH 3/6] Use strip that is truthfully reconstructed from env['STRIP'] --- pythonforandroid/bootstrap.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/pythonforandroid/bootstrap.py b/pythonforandroid/bootstrap.py index 05dfdff01d..b7c3828bed 100755 --- a/pythonforandroid/bootstrap.py +++ b/pythonforandroid/bootstrap.py @@ -263,11 +263,8 @@ def strip_libraries(self, arch): info('Python was loaded from CrystaX, skipping strip') return env = arch.get_env() - strip = env['STRIP'].split(' ')[0] - if strip is None: - warning('Can\'t find strip in PATH...') - return - strip = sh.Command(strip).bake('--strip-unneeded') + tokens = env['STRIP'].split(' ') + strip = reduce(lambda cmd, t: cmd.bake(t), tokens, sh.Command(tokens.pop(0))) libs_dir = join(self.dist_dir, '_python_bundle', '_python_bundle', 'modules') From 8cd69dc459959a8ab472510920842c51684f57c4 Mon Sep 17 00:00:00 2001 From: jayd Date: Sun, 27 Jan 2019 11:43:21 +0700 Subject: [PATCH 4/6] Simplify strip command construction and use shlex.split --- pythonforandroid/bootstrap.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pythonforandroid/bootstrap.py b/pythonforandroid/bootstrap.py index b7c3828bed..c25be31989 100755 --- a/pythonforandroid/bootstrap.py +++ b/pythonforandroid/bootstrap.py @@ -1,6 +1,7 @@ from os.path import (join, dirname, isdir, normpath, splitext, basename) from os import listdir, walk, sep import sh +import shlex import glob import importlib import os @@ -263,8 +264,8 @@ def strip_libraries(self, arch): info('Python was loaded from CrystaX, skipping strip') return env = arch.get_env() - tokens = env['STRIP'].split(' ') - strip = reduce(lambda cmd, t: cmd.bake(t), tokens, sh.Command(tokens.pop(0))) + tokens = shlex.split(env['STRIP']) + strip = sh.Command(tokens[0]).bake(tokens[1:]) libs_dir = join(self.dist_dir, '_python_bundle', '_python_bundle', 'modules') From 7ad0207721aa75dc7e1727118f88ce08f8bdb877 Mon Sep 17 00:00:00 2001 From: jayd Date: Thu, 31 Jan 2019 00:15:21 +0700 Subject: [PATCH 5/6] Add a check to bake strip command's options only when they exist --- pythonforandroid/bootstrap.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pythonforandroid/bootstrap.py b/pythonforandroid/bootstrap.py index c25be31989..1b64213986 100755 --- a/pythonforandroid/bootstrap.py +++ b/pythonforandroid/bootstrap.py @@ -265,7 +265,9 @@ def strip_libraries(self, arch): return env = arch.get_env() tokens = shlex.split(env['STRIP']) - strip = sh.Command(tokens[0]).bake(tokens[1:]) + strip = sh.Command(tokens[0]) + if len(tokens) > 1: + strip = strip.bake(tokens[1:]) libs_dir = join(self.dist_dir, '_python_bundle', '_python_bundle', 'modules') From 06f2d3956f116989c731a86b136feefefe3b838e Mon Sep 17 00:00:00 2001 From: jayd Date: Thu, 31 Jan 2019 15:54:19 +0700 Subject: [PATCH 6/6] Remove unused import of pythonforandroid.util.which --- pythonforandroid/bootstrap.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pythonforandroid/bootstrap.py b/pythonforandroid/bootstrap.py index 1b64213986..0bfe68c83f 100755 --- a/pythonforandroid/bootstrap.py +++ b/pythonforandroid/bootstrap.py @@ -10,7 +10,7 @@ from pythonforandroid.logger import (warning, shprint, info, logger, debug) from pythonforandroid.util import (current_directory, ensure_dir, - temp_directory, which) + temp_directory) from pythonforandroid.recipe import Recipe