kivy-ios/.ci/rebuild_updated_recipes.py
Andre Miras 56431b6922 Moving to dedicated kivy_ios/ package directory
- updates all imports to prefix kivy_ios
- adds basic `setup.py` file
- adds a simple `toolchain.py` to the root folder for compat

Makes it possible to install kivy-ios from PyPI:
```
pip install kivy-ios
toolchain --help
```
Note the `rebuild_updated_recipes.py` is expected to fail as we
moved all the recipes.

This is a working, but unperfect iteration that come with limitations
we would address in subsequent pull requests, such as:
- the new usage is not yet documented
- CI is not testing the source distribution creation and install
- Continuous Delivery to PyPI is not in place
- `toolchain` binary is a bit too generic name
- we're still vendoring things under `tools/`
2020-05-03 23:29:41 +02:00

48 lines
1.4 KiB
Python

#!/usr/bin/env python
"""
Continuous Integration helper script.
Automatically detects recipes modified in a changeset (compares with master)
and recompiles them.
Current limitations:
- will fail on conflicting requirements
"""
import sh
import subprocess
from fnmatch import fnmatch
from constants import CORE_RECIPES, BROKEN_RECIPES
def modified_recipes(branch="origin/master"):
"""
Returns a set of modified recipes between the current branch and the one
in param.
"""
# using the contrib version on purpose rather than sh.git, since it comes
# with a bunch of fixes, e.g. disabled TTY, see:
# https://stackoverflow.com/a/20128598/185510
sh.contrib.git.fetch("origin", "master")
git_diff = sh.contrib.git.diff("--name-only", branch)
recipes = set()
for file_path in git_diff:
if fnmatch(file_path, "kivy_ios/recipes/*/__init__.py\n"):
recipe = file_path.split("/")[1]
recipes.add(recipe)
return recipes
def main():
recipes = modified_recipes()
recipes -= CORE_RECIPES
recipes -= BROKEN_RECIPES
updated_recipes = " ".join(recipes)
if updated_recipes != "":
subprocess.run(
f"python3 toolchain.py build {updated_recipes}", shell=True, check=True
)
else:
print("Nothing to do. No updated recipes.")
if __name__ == "__main__":
main()