24
24
import sh
25
25
import os
26
26
from pythonforandroid .build import Context
27
+ from pythonforandroid import logger
27
28
from pythonforandroid .graph import get_recipe_order_and_bootstrap
28
29
from pythonforandroid .toolchain import current_directory
30
+ from pythonforandroid .util import BuildInterruptingException
29
31
from ci .constants import TargetPython , CORE_RECIPES , BROKEN_RECIPES
30
32
31
33
@@ -59,9 +61,10 @@ def build(target_python, requirements):
59
61
testapp = 'setup_testapp_python3.py'
60
62
requirements .add (target_python .name )
61
63
requirements = ',' .join (requirements )
62
- print ('requirements:' , requirements )
64
+ logger . info ('requirements: {}' . format ( requirements ) )
63
65
with current_directory ('testapps/' ):
64
66
try :
67
+ # iterates to stream the output
65
68
for line in sh .python (
66
69
testapp , 'apk' , '--sdk-dir' , android_sdk_home ,
67
70
'--ndk-dir' , android_ndk_home , '--bootstrap' , 'sdl2' , '--requirements' ,
@@ -74,21 +77,24 @@ def build(target_python, requirements):
74
77
def main ():
75
78
target_python = TargetPython .python3
76
79
recipes = modified_recipes ()
77
- print ('recipes modified:' , recipes )
80
+ logger . info ('recipes modified: {}' . format ( recipes ) )
78
81
recipes -= CORE_RECIPES
79
- print ('recipes to build:' , recipes )
82
+ logger . info ('recipes to build: {}' . format ( recipes ) )
80
83
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 ))
86
92
target_python = TargetPython .python2
87
- print ('falling back to {}' .format (target_python .name ))
93
+ logger . info ('falling back to {}' .format (target_python .name ))
88
94
# removing the known broken recipe for the given target
89
95
broken_recipes = BROKEN_RECIPES [target_python ]
90
96
recipes -= broken_recipes
91
- print ('recipes to build (no broken):' , recipes )
97
+ logger . info ('recipes to build (no broken): {}' . format ( recipes ) )
92
98
build (target_python , recipes )
93
99
94
100
0 commit comments