From 625183d27ea1b890db50a56f6ec670b18e8eb593 Mon Sep 17 00:00:00 2001 From: Peter Badida Date: Sat, 8 Oct 2016 14:38:43 +0200 Subject: [PATCH] Fix bdistapk for launcher --- pythonforandroid/bdistapk.py | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/pythonforandroid/bdistapk.py b/pythonforandroid/bdistapk.py index 3d10e26400..f81884a2c8 100644 --- a/pythonforandroid/bdistapk.py +++ b/pythonforandroid/bdistapk.py @@ -80,7 +80,7 @@ def run(self): def prepare_build_dir(self): - if argv_contains('--private'): + if argv_contains('--private') and not argv_contains('--launcher'): print('WARNING: Received --private argument when this would ' 'normally be generated automatically.') print(' This is probably bad unless you meant to do ' @@ -101,18 +101,19 @@ def prepare_build_dir(self): filens.extend(glob(pattern)) main_py_dirs = [] - for filen in filens: - new_dir = join(bdist_dir, dirname(filen)) - if not exists(new_dir): - makedirs(new_dir) - print('Including {}'.format(filen)) - copyfile(filen, join(bdist_dir, filen)) - if basename(filen) in ('main.py', 'main.pyo'): - main_py_dirs.append(filen) + if not argv_contains('--launcher'): + for filen in filens: + new_dir = join(bdist_dir, dirname(filen)) + if not exists(new_dir): + makedirs(new_dir) + print('Including {}'.format(filen)) + copyfile(filen, join(bdist_dir, filen)) + if basename(filen) in ('main.py', 'main.pyo'): + main_py_dirs.append(filen) # This feels ridiculous, but how else to define the main.py dir? # Maybe should just fail? - if len(main_py_dirs) == 0: + if not main_py_dirs and not argv_contains('--launcher'): print('ERROR: Could not find main.py, so no app build dir defined') print('You should name your app entry point main.py') exit(1) @@ -120,8 +121,10 @@ def prepare_build_dir(self): print('WARNING: Multiple main.py dirs found, using the shortest path') main_py_dirs = sorted(main_py_dirs, key=lambda j: len(split(j))) - sys.argv.append('--private={}'.format(join(realpath(curdir), bdist_dir, - dirname(main_py_dirs[0])))) + if not argv_contains('--launcher'): + sys.argv.append('--private={}'.format( + join(realpath(curdir), bdist_dir, dirname(main_py_dirs[0]))) + ) def _set_user_options(): @@ -138,4 +141,4 @@ def _set_user_options(): BdistAPK.user_options = user_options -_set_user_options() +_set_user_options() \ No newline at end of file