Skip to content

Commit

Permalink
Merge pull request #896 from KeyWeeUsr/fix_bdist
Browse files Browse the repository at this point in the history
Fix bdistapk for launcher
  • Loading branch information
inclement authored Nov 25, 2016
2 parents 8731695 + 625183d commit 9168221
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions pythonforandroid/bdistapk.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,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 '
Expand All @@ -105,27 +105,30 @@ 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)
if len(main_py_dirs) > 1:
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():
Expand Down

0 comments on commit 9168221

Please sign in to comment.