Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix strip in bootstrap #1607

Merged
merged 6 commits into from
Jan 31, 2019
Merged
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions pythonforandroid/bootstrap.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -263,11 +264,10 @@ 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'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since which is not used anymore, would you mind removing the import to please the CI 🙏

pythonforandroid/bootstrap.py:12:1: F401 'pythonforandroid.util.which' imported but unused

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. Sorry about the CI. Thanks for your help.

if strip is None:
warning('Can\'t find strip in PATH...')
return
strip = sh.Command(strip)
tokens = shlex.split(env['STRIP'])
strip = sh.Command(tokens[0])
if len(tokens) > 1:
Copy link

@ghost ghost Jan 30, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have you tested this without the if and a single argument/len(tokens) == 1? I tested bake with an empty list and it worked fine, I'm pretty sure this conditional is not required

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, you're quite right, I misremembered what list slice syntax would do outside the bounds of the list. It's fine to revert this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Jonast Yes, I tested the len(tokens) == 1 case, and it basically works. But, I found that .bake() raises a complaint when it's argument is [] (see the following REPL test).

>>> import sh
>>> sh.Command('strip').bake([])
__main__:1: UserWarning: Empty list passed as an argument to '/opt/local/bin/strip'. If you're using glob.glob(), please use sh.glob() instead.

If we want to eliminate this warning, I think we still need the if check. Thoughts? @Jonast @inclement

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@j-devel oh weird, have never seen that (maybe I got a different version?). In that case definitely keep the check in

strip = strip.bake(tokens[1:])

libs_dir = join(self.dist_dir, '_python_bundle',
'_python_bundle', 'modules')
Expand All @@ -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:
Expand Down