8000 Fixed bugs in new dependency graph resolution · ikewang/python-for-android@7339b27 · GitHub
[go: up one dir, main page]

Skip to content

Commit 7339b27

Browse files
committed
Fixed bugs in new dependency graph resolution
1 parent bfd675a commit 7339b27

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

pythonforandroid/graph.py

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11

22
from copy import deepcopy
33
from itertools import product
4+
from sys import exit
45

5-
from pythonforandroid.logger import (info, info_notify, warning)
6+
from pythonforandroid.logger import (info, info_notify, warning, error)
67
from pythonforandroid.recipe import Recipe
78
from pythonforandroid.bootstrap import Bootstrap
89

@@ -219,27 +220,41 @@ def new_get_recipe_order_and_bootstrap(ctx, names, bs=None):
219220
try:
220221
order = find_order(possible_order)
221222
except ValueError: # a circular dependency was found
222-
info('Circular dependency found in graph {}'.format(possible_order))
223+
info('Circular dependency found in graph {}, skipping it.'.format(possible_order))
223224
continue
225+
except:
226+
warning('Failed to import recipe named {}; the recipe exists '
227+
'but appears broken.'.format(name))
228+
warning('Exception was:')
229+
raise
224230
orders.append(list(order))
225231

226232
# prefer python2 and SDL2 if available
227233
orders = sorted(orders,
228234
key=lambda order: -('python2' in order) - ('sdl2' in order))
229235

236+
if not orders:
237+
error('Didn\'t find any valid dependency graphs.')
238+
error('This means that some of your requirements pull in conflicting dependencies.')
239+
error('Exiting.')
240+
exit(1)
230241
# It would be better to check against possible orders other
231242
# than the first one, but in practice clashes will be rare,
232243
# and can be resolved by specifying more parameters
233-
order = orders[0]
234-
235-
print('pre-bs order is', order)
244+
chosen_order = orders[0]
245+
if len(orders) > 1:
246+
info('Found multiple valid dependency orders:')
247+
for order in orders:
248+
info(' {}'.format(order))
249+
info('Using the first of these: {}'.format(chosen_order))
250+
else:
251+
info('Found a single valid recipe set: {}'.format(chosen_order))
236252

237253
if bs is None:
238-
bs = Bootstrap.get_bootstrap_from_recipes(order, ctx)
239-
orders, bs = new_get_recipe_order_and_bootstrap(ctx, order, bs=bs)
240-
order = orders[0]
241-
242-
return order, bs
254+
bs = Bootstrap.get_bootstrap_from_recipes(chosen_order, ctx)
255+
chosen_order, bs = new_get_recipe_order_and_bootstrap(ctx, chosen_order, bs=bs)
256+
257+
return chosen_order, bs
243258

244259

245260

0 commit comments

Comments
 (0)
0