Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make bootstrap dynamic for travis conditional builds #1594

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ci/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@

class TargetPython(Enum):
python2 = 0
python3crystax = 1
python3 = 2
python3 = 1


# recipes that currently break the build
Expand Down Expand Up @@ -64,6 +63,7 @@ class TargetPython(Enum):
'zeroconf',
'zope',
])
# to be created via https://github.com/kivy/python-for-android/issues/1514
BROKEN_RECIPES_PYTHON3 = set([
'brokenrecipe',
# enum34 is not compatible with Python 3.6 standard library
Expand Down
64 changes: 47 additions & 17 deletions ci/rebuild_updated_recipes.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def modified_recipes(branch='origin/master'):
return recipes


def build(target_python, requirements):
def build(target_python, target_bootstrap, requirements):
"""
Builds an APK given a target Python and a set of requirements.
"""
Expand All @@ -65,34 +65,64 @@ def build(target_python, requirements):
with current_directory('testapps/'):
# iterates to stream the output
for line in sh.python(
testapp, 'apk', '--sdk-dir', android_sdk_home,
'--ndk-dir', android_ndk_home, '--bootstrap', 'sdl2', '--requirements',
requirements, _err_to_out=True, _iter=True):
testapp, 'apk',
'--sdk-dir', android_sdk_home,
'--ndk-dir', android_ndk_home,
'--bootstrap', target_bootstrap,
'--requirements', requirements,
_err_to_out=True, _iter=True):
print(line)


def main():
target_python = TargetPython.python3
recipes = modified_recipes()
logger.info('recipes modified: {}'.format(recipes))
recipes -= CORE_RECIPES
logger.info('recipes to build: {}'.format(recipes))
def get_bootstrap(recipes_and_target):
"""
Finds the right bootstrap given a set of requirements with a defined
target python recipe inside this set.
"""
context = Context()
# forces the default target
recipes_and_target = recipes | set([target_python.name])
bootstrap = None
try:
build_order, python_modules, bs = get_recipe_order_and_bootstrap(
context, recipes_and_target, None)
bootstrap = bs.name
except BuildInterruptingException:
# fallback to python2 if default target is not compatible
logger.info('incompatible with {}'.format(target_python.name))
target_python = TargetPython.python2
logger.info('falling back to {}'.format(target_python.name))
pass
return bootstrap


def main():
target_python_priorities = [
TargetPython.python3,
TargetPython.python2
]

recipes = modified_recipes()
logger.info('recipes modified: {}'.format(recipes))
recipes -= CORE_RECIPES
logger.info('recipes to build: {}'.format(recipes))

# iterate over `target_python_priorities` in order to find the
# python version that is compatible with the modified recipes
bootstrap = None
target_python = None
for target_python in target_python_priorities:
logger.info('trying to get a bootstrap forcing target python: {}'.
format(target_python.name))
bootstrap = get_bootstrap(recipes | {target_python.name})
if bootstrap:
break
if not bootstrap:
logger.warning("we didn't find any valid combination of bootstrap and "
"target python...rebuild updated recipes cancelled."
"The recipes we couldn't rebuild are:\n\t-{}".format(
"\n\t-".join(recipes)))
exit(1)

# removing the known broken recipe for the given target
broken_recipes = BROKEN_RECIPES[target_python]
recipes -= broken_recipes
logger.info('recipes to build (no broken): {}'.format(recipes))
build(target_python, recipes)
build(target_python, bootstrap, recipes)


if __name__ == '__main__':
Expand Down