Skip to content

Commit 2b61b8b

Browse files
authored
Merge pull request kivy#1809 from JonasT/runsetupfixnotapkcmds
[WIP] Fix crashes when using other commands than 'apk'
2 parents 8e0e805 + 990adc2 commit 2b61b8b

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

pythonforandroid/build.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,8 @@ def project_has_setup_py(project_dir):
593593
return False
594594

595595

596-
def run_pymodules_install(ctx, modules, project_dir, ignore_setup_py=False):
596+
def run_pymodules_install(ctx, modules, project_dir=None,
597+
ignore_setup_py=False):
597598
""" This function will take care of all non-recipe things, by:
598599
599600
1. Processing them from --requirements (the modules argument)
@@ -610,6 +611,7 @@ def run_pymodules_install(ctx, modules, project_dir, ignore_setup_py=False):
610611
# Bail out if no python deps and no setup.py to process:
611612
if not modules and (
612613
ignore_setup_py or
614+
project_dir is None or
613615
not project_has_setup_py(project_dir)
614616
):
615617
info('No Python modules and no setup.py to process, skipping')
@@ -621,7 +623,8 @@ def run_pymodules_install(ctx, modules, project_dir, ignore_setup_py=False):
621623
'install them with pip'.format(', '.join(modules)))
622624
info('If this fails, it may mean that the module has compiled '
623625
'components and needs a recipe.')
624-
if project_has_setup_py(project_dir) and not ignore_setup_py:
626+
if project_dir is not None and \
627+
project_has_setup_py(project_dir) and not ignore_setup_py:
625628
info('Will process project install, if it fails then the '
626629
'project may not be compatible for Android install.')
627630

@@ -694,7 +697,9 @@ def run_pymodules_install(ctx, modules, project_dir, ignore_setup_py=False):
694697
_env=copy.copy(env))
695698

696699
# Afterwards, run setup.py if present:
697-
if project_has_setup_py(project_dir) and not ignore_setup_py:
700+
if project_dir is not None and (
701+
project_has_setup_py(project_dir) and not ignore_setup_py
702+
):
698703
with current_directory(project_dir):
699704
info('got setup.py or similar, running project install. ' +
700705
'(disable this behavior with --ignore-setup-py)')

pythonforandroid/toolchain.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,11 @@ def build_dist_from_args(ctx, dist, args):
199199
if dist.needs_build:
200200
ctx.prepare_dist(ctx.dist_name)
201201

202-
build_recipes(build_order, python_modules, ctx, args.private,
203-
ignore_project_setup_py=args.ignore_setup_py,
202+
build_recipes(build_order, python_modules, ctx,
203+
getattr(args, "private", None),
204+
ignore_project_setup_py=getattr(
205+
args, "ignore_setup_py", False
206+
),
204207
)
205208

206209
ctx.bootstrap.run_distribute()
@@ -568,7 +571,7 @@ def add_parser(subparsers, *args, **kwargs):
568571
if hasattr(args, "private") and args.private is not None:
569572
# Pass this value on to the internal bootstrap build.py:
570573
args.unknown_args += ["--private", args.private]
571-
if args.ignore_setup_py:
574+
if hasattr(args, "ignore_setup_py") and args.ignore_setup_py:
572575
args.use_setup_py = False
573576

574577
self.args = args
@@ -583,7 +586,7 @@ def add_parser(subparsers, *args, **kwargs):
583586
logger.setLevel(logging.DEBUG)
584587

585588
self.ctx = Context()
586-
self.ctx.use_setup_py = args.use_setup_py
589+
self.ctx.use_setup_py = getattr(args, "use_setup_py", True)
587590

588591
have_setup_py_or_similar = False
589592
if getattr(args, "private", None) is not None:

0 commit comments

Comments
 (0)