2424import sh
2525import os
2626from pythonforandroid .build import Context
27+ from pythonforandroid import logger
2728from pythonforandroid .graph import get_recipe_order_and_bootstrap
2829from pythonforandroid .toolchain import current_directory
30+ from pythonforandroid .util import BuildInterruptingException
2931from ci .constants import TargetPython , CORE_RECIPES , BROKEN_RECIPES
3032
3133
@@ -59,9 +61,10 @@ def build(target_python, requirements):
5961 testapp = 'setup_testapp_python3.py'
6062 requirements .add (target_python .name )
6163 requirements = ',' .join (requirements )
62- print ('requirements:' , requirements )
64+ logger . info ('requirements: {}' . format ( requirements ) )
6365 with current_directory ('testapps/' ):
6466 try :
67+ # iterates to stream the output
6568 for line in sh .python (
6669 testapp , 'apk' , '--sdk-dir' , android_sdk_home ,
6770 '--ndk-dir' , android_ndk_home , '--bootstrap' , 'sdl2' , '--requirements' ,
@@ -74,21 +77,24 @@ def build(target_python, requirements):
7477def main ():
7578 target_python = TargetPython .python3
7679 recipes = modified_recipes ()
77- print ('recipes modified:' , recipes )
80+ logger . info ('recipes modified: {}' . format ( recipes ) )
7881 recipes -= CORE_RECIPES
79- print ('recipes to build:' , recipes )
82+ logger . info ('recipes to build: {}' . format ( recipes ) )
8083 context = Context ()
81- build_order , python_modules , bs = get_recipe_order_and_bootstrap (
82- context , recipes , None )
83- # fallback to python2 if default target is not compatible
84- if target_python .name not in build_order :
85- print ('incompatible with {}' .format (target_python .name ))
84+ # forces the default target
85+ recipes_and_target = recipes | set ([target_python .name ])
86+ try :
87+ build_order , python_modules , bs = get_recipe_order_and_bootstrap (
88+ context , recipes_and_target , None )
89+ except BuildInterruptingException :
90+ # fallback to python2 if default target is not compatible
91+ logger .info ('incompatible with {}' .format (target_python .name ))
8692 target_python = TargetPython .python2
87- print ('falling back to {}' .format (target_python .name ))
93+ logger . info ('falling back to {}' .format (target_python .name ))
8894 # removing the known broken recipe for the given target
8995 broken_recipes = BROKEN_RECIPES [target_python ]
9096 recipes -= broken_recipes
91- print ('recipes to build (no broken):' , recipes )
97+ logger . info ('recipes to build (no broken): {}' . format ( recipes ) )
9298 build (target_python , recipes )
9399
94100
0 commit comments