Skip to content

Commit

Permalink
[bootstrap] Fix crash when guessing Bootstrap (expand_dependencies)
Browse files Browse the repository at this point in the history
When a pure python package it's supplied inside the dependency list (for the method `expand_dependencies`), we will get a crash because we don't have a recipe for it, unless we contemplate that situation
  • Loading branch information
opacam committed Jul 10, 2019
1 parent 108d49c commit 6d6ab20
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
9 changes: 7 additions & 2 deletions pythonforandroid/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,13 @@ def expand_dependencies(recipes, ctx):
if not isinstance(entry, (tuple, list)) or len(entry) == 1:
if isinstance(entry, (tuple, list)):
entry = entry[0]
recipe = Recipe.get_recipe(entry, ctx)
recipes_with_deps += recipe.depends
try:
recipe = Recipe.get_recipe(entry, ctx)
recipes_with_deps += recipe.depends
except ValueError:
# it's a pure python package without a recipe, so we
# don't know the dependencies...skipping for now
pass

# Split up lists by available alternatives:
recipe_lists = [[]]
Expand Down
12 changes: 12 additions & 0 deletions tests/test_bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,18 @@ def test_expand_dependencies(self):
expanded_result_2 = expand_dependencies([("pysdl2", "kivy")], self.ctx)
self.assertEqual([["pysdl2"], ["kivy"]], expanded_result_2)

def test_expand_dependencies_with_pure_python_package(self):
"""Check that `expanded_dependencies`, with a pure python package as
one of the dependencies, returns a list of dependencies
"""
expanded_result = expand_dependencies(
["python3", "kivy", "peewee"], self.ctx
)
self.assertEqual(len(expanded_result), 3)
self.assertIsInstance(expanded_result, list)
for i in expanded_result:
self.assertIsInstance(i, list)

def test_get_bootstraps_from_recipes(self):
"""A test which will initialize a bootstrap and will check if the
method :meth:`~pythonforandroid.bootstrap.Bootstrap.
Expand Down

0 comments on commit 6d6ab20

Please sign in to comment.