MCPcopy Index your code
hub / github.com/kivy/python-for-android / get_bootstrap_from_recipes

Method get_bootstrap_from_recipes

pythonforandroid/bootstrap.py:294–345  ·  view source on GitHub ↗

Picks a single recommended default bootstrap out of all_usable_bootstraps_from_recipes() for the given reicpes, and returns it.

(cls, recipes, ctx)

Source from the content-addressed store, hash-verified

292
293 @classmethod
294 def get_bootstrap_from_recipes(cls, recipes, ctx):
295 '''Picks a single recommended default bootstrap out of
296 all_usable_bootstraps_from_recipes() for the given reicpes,
297 and returns it.'''
298
299 known_web_packages = {"flask"} # to pick webview over service_only
300 recipes_with_deps_lists = expand_dependencies(recipes, ctx)
301 acceptable_bootstraps = cls.get_usable_bootstraps_for_recipes(
302 recipes, ctx
303 )
304
305 def have_dependency_in_recipes(dep):
306 for dep_list in recipes_with_deps_lists:
307 if dep in dep_list:
308 return True
309 return False
310
311 # Special rule: return SDL2 bootstrap if there's an sdl2 dep:
312 if (have_dependency_in_recipes("sdl2") and
313 "sdl2" in [b.name for b in acceptable_bootstraps]
314 ):
315 info('Using sdl2 bootstrap since it is in dependencies')
316 return cls.get_bootstrap("sdl2", ctx)
317
318 # Special rule: return SDL3 bootstrap if there's an sdl3 dep:
319 if (have_dependency_in_recipes("sdl3") and
320 "sdl3" in [b.name for b in acceptable_bootstraps]
321 ):
322 info('Using sdl3 bootstrap since it is in dependencies')
323 return cls.get_bootstrap("sdl3", ctx)
324
325 # Special rule: return "webview" if we depend on common web recipe:
326 for possible_web_dep in known_web_packages:
327 if have_dependency_in_recipes(possible_web_dep):
328 # We have a web package dep!
329 if "webview" in [b.name for b in acceptable_bootstraps]:
330 info('Using webview bootstrap since common web packages '
331 'were found {}'.format(
332 known_web_packages.intersection(recipes)
333 ))
334 return cls.get_bootstrap("webview", ctx)
335
336 prioritized_acceptable_bootstraps = sorted(
337 list(acceptable_bootstraps),
338 key=functools.cmp_to_key(_cmp_bootstraps_by_priority)
339 )
340
341 if prioritized_acceptable_bootstraps:
342 info('Using the highest ranked/first of these: {}'
343 .format(prioritized_acceptable_bootstraps[0].name))
344 return prioritized_acceptable_bootstraps[0]
345 return None
346
347 @classmethod
348 def get_bootstrap(cls, name, ctx):

Calls 4

expand_dependenciesFunction · 0.85
get_bootstrapMethod · 0.80
formatMethod · 0.80

Tested by 1