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 bdistapk for launcher #896

Merged
merged 1 commit into from
Nov 25, 2016
Merged
Changes from all 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
29 changes: 16 additions & 13 deletions pythonforandroid/bdistapk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 '
Expand All @@ -101,27 +101,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 All @@ -138,4 +141,4 @@ def _set_user_options():

BdistAPK.user_options = user_options

_set_user_options()
_set_user_options()