@@ -48,7 +48,7 @@ def modified_recipes(branch='origin/master'):
48
48
return recipes
49
49
50
50
51
- def build (target_python , requirements ):
51
+ def build (target_python , target_bootstrap , requirements ):
52
52
"""
53
53
Builds an APK given a target Python and a set of requirements.
54
54
"""
@@ -65,34 +65,71 @@ def build(target_python, requirements):
65
65
with current_directory ('testapps/' ):
66
66
# iterates to stream the output
67
67
for line in sh .python (
68
- testapp , 'apk' , '--sdk-dir' , android_sdk_home ,
69
- '--ndk-dir' , android_ndk_home , '--bootstrap' , 'sdl2' , '--requirements' ,
70
- requirements , _err_to_out = True , _iter = True ):
68
+ testapp , 'apk' ,
69
+ '--sdk-dir' , android_sdk_home ,
70
+ '--ndk-dir' , android_ndk_home ,
71
+ '--bootstrap' , target_bootstrap ,
72
+ '--requirements' , requirements ,
73
+ _err_to_out = True , _iter = True ):
71
74
print (line )
72
75
73
76
74
- def main ():
75
- target_python = TargetPython .python3
76
- recipes = modified_recipes ()
77
- logger .info ('recipes modified: {}' .format (recipes ))
78
- recipes -= CORE_RECIPES
79
- logger .info ('recipes to build: {}' .format (recipes ))
77
+ def get_bootstrap (recipes_and_target ):
78
+ """
79
+ Finds the right bootstrap given a set of requirements with a defined
80
+ target python recipe inside this set.
81
+ """
80
82
context = Context ()
81
- # forces the default target
82
- recipes_and_target = recipes | set ([target_python .name ])
83
+ bootstrap = None
83
84
try :
84
85
build_order , python_modules , bs = get_recipe_order_and_bootstrap (
85
86
context , recipes_and_target , None )
87
+ bootstrap = bs .name
86
88
except BuildInterruptingException :
87
- # fallback to python2 if default target is not compatible
88
- logger .info ('incompatible with {}' .format (target_python .name ))
89
- target_python = TargetPython .python2
90
- logger .info ('falling back to {}' .format (target_python .name ))
89
+ pass
90
+ return bootstrap
91
+
92
+
93
+ def main ():
94
+ target_python_priorities = [
95
+ TargetPython .python3 ,
96
+ TargetPython .python2 ,
97
+ TargetPython .python2legacy
98
+ ]
99
+
100
+ recipes = modified_recipes ()
101
+ logger .info ('recipes modified: {}' .format (recipes ))
102
+ recipes -= CORE_RECIPES
103
+ logger .info ('recipes to build: {}' .format (recipes ))
104
+
105
+ bootstrap = None
106
+ target_python = None
107
+ for n , target_python in enumerate (target_python_priorities ):
108
+ logger .info (
109
+ 'trying to get a bootstrap forcing target python: {}' .format (
110
+ target_python .name ))
111
+ bootstrap = get_bootstrap (recipes | {target_python .name })
112
+ if bootstrap :
113
+ break
114
+ else :
115
+ # fallback to next TargetPython if current target is not compatible
116
+ logger .info ('\t - incompatible with {}' .format (target_python .name ))
117
+ if len (target_python_priorities ) < n + 1 :
118
+ logger .info ('\t - falling back to {}' .format (
119
+ target_python_priorities [n + 1 ].name ))
120
+ continue
121
+ if not bootstrap :
122
+ logger .warning ('we didn\' t find any valid combination of bootstrap and'
123
+ ' target python...rebuild updated recipes cancelled.'
124
+ 'The recipes we couldn\' t rebuild are:'
125
+ '\n \t -{}' .format ('\n \t -' .join (list (recipes ))))
126
+ exit (1 )
127
+
91
128
# removing the known broken recipe for the given target
92
129
broken_recipes = BROKEN_RECIPES [target_python ]
93
130
recipes -= broken_recipes
94
131
logger .info ('recipes to build (no broken): {}' .format (recipes ))
95
- build (target_python , recipes )
132
+ build (target_python , bootstrap , recipes )
96
133
97
134
98
135
if __name__ == '__main__' :
0 commit comments