Skip to content

Commit 21004a7

Browse files
authored
Merge pull request #1914 from opacam/hotfix-fix-bootstrap-py-deps
Fix crash when guessing Bootstrap (expand_dependencies)
2 parents 108d49c + 6d6ab20 commit 21004a7

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

pythonforandroid/bootstrap.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -394,8 +394,13 @@ def expand_dependencies(recipes, ctx):
394394
if not isinstance(entry, (tuple, list)) or len(entry) == 1:
395395
if isinstance(entry, (tuple, list)):
396396
entry = entry[0]
397-
recipe = Recipe.get_recipe(entry, ctx)
398-
recipes_with_deps += recipe.depends
397+
try:
398+
recipe = Recipe.get_recipe(entry, ctx)
399+
recipes_with_deps += recipe.depends
400+
except ValueError:
401+
# it's a pure python package without a recipe, so we
402+
# don't know the dependencies...skipping for now
403+
pass
399404

400405
# Split up lists by available alternatives:
401406
recipe_lists = [[]]

tests/test_bootstrap.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,18 @@ def test_expand_dependencies(self):
171171
expanded_result_2 = expand_dependencies([("pysdl2", "kivy")], self.ctx)
172172
self.assertEqual([["pysdl2"], ["kivy"]], expanded_result_2)
173173

174+
def test_expand_dependencies_with_pure_python_package(self):
175+
"""Check that `expanded_dependencies`, with a pure python package as
176+
one of the dependencies, returns a list of dependencies
177+
"""
178+
expanded_result = expand_dependencies(
179+
["python3", "kivy", "peewee"], self.ctx
180+
)
181+
self.assertEqual(len(expanded_result), 3)
182+
self.assertIsInstance(expanded_result, list)
183+
for i in expanded_result:
184+
self.assertIsInstance(i, list)
185+
174186
def test_get_bootstraps_from_recipes(self):
175187
"""A test which will initialize a bootstrap and will check if the
176188
method :meth:`~pythonforandroid.bootstrap.Bootstrap.

0 commit comments

Comments
 (0)