Skip to content

Commit 6962a90

Browse files
committed
Made bootstrap recipe alternatives work
1 parent cd6b78d commit 6962a90

File tree

2 files changed

+33
-15
lines changed

2 files changed

+33
-15
lines changed

pythonforandroid/bootstrap.py

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -138,19 +138,22 @@ def get_bootstrap_from_recipes(cls, recipes, ctx):
138138
ok = True
139139
if not bs.can_be_chosen_automatically:
140140
ok = False
141-
for recipe in bs.recipe_depends:
142-
recipe = Recipe.get_recipe(recipe, ctx)
143-
if any([conflict in recipes for conflict in recipe.conflicts]):
144-
ok = False
145-
break
146-
for recipe in recipes:
147-
recipe = Recipe.get_recipe(recipe, ctx)
148-
if any([conflict in bs.recipe_depends
149-
for conflict in recipe.conflicts]):
150-
ok = False
151-
break
152-
if ok:
153-
acceptable_bootstraps.append(bs)
141+
possible_dependency_lists = expand_dependencies(bs.recipe_depends)
142+
for possible_dependencies in possible_dependency_lists:
143+
ok = True
144+
for recipe in possible_dependencies:
145+
recipe = Recipe.get_recipe(recipe, ctx)
146+
if any([conflict in recipes for conflict in recipe.conflicts]):
147+
ok = False
148+
break
149+
for recipe in recipes:
150+
recipe = Recipe.get_recipe(recipe, ctx)
151+
if any([conflict in possible_dependencies
152+
for conflict in recipe.conflicts]):
153+
ok = False
154+
break
155+
if ok:
156+
acceptable_bootstraps.append(bs)
154157
info('Found {} acceptable bootstraps: {}'.format(
155158
len(acceptable_bootstraps),
156159
[bs.name for bs in acceptable_bootstraps]))
@@ -264,3 +267,20 @@ def fry_eggs(self, sitepackages):
264267
if files:
265268
shprint(sh.mv, '-t', sitepackages, *files)
266269
shprint(sh.rm, '-rf', d)
270+
271+
272+
def expand_dependencies(recipes):
273+
recipe_lists = [[]]
274+
for recipe in recipes:
275+
if isinstance(recipe, (tuple, list)):
276+
new_recipe_lists = []
277+
for alternative in recipe:
278+
for old_list in recipe_lists:
279+
new_list = [i for i in old_list]
280+
new_list.append(alternative)
281+
new_recipe_lists.append(new_list)
282+
recipe_lists = new_recipe_lists
283+
else:
284+
for old_list in recipe_lists:
285+
old_list.append(recipe)
286+
return recipe_lists

pythonforandroid/logger.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,5 +217,3 @@ def printtail(out, name, forecolor, tail_n=0,
217217

218218
return output
219219

220-
221-
from pythonforandroid.util import unistr

0 commit comments

Comments
 (0)