diff --git a/infra/config/recipes.cfg b/infra/config/recipes.cfg index 3a200c69ed..c9c7ee6181 100644 --- a/infra/config/recipes.cfg +++ b/infra/config/recipes.cfg @@ -16,7 +16,7 @@ "deps": { "recipe_engine": { "branch": "refs/heads/main", - "revision": "5226416ff445b80b55042d5e28d51b5da035f48d", + "revision": "8f92d0c510bcddd3c369a14d222ecc18d7c63783", "url": "https://chromium.googlesource.com/infra/luci/recipes-py.git" } }, diff --git a/recipes/README.recipes.md b/recipes/README.recipes.md index 6668fa4546..516b0760ed 100644 --- a/recipes/README.recipes.md +++ b/recipes/README.recipes.md @@ -1201,25 +1201,25 @@ PYTHON_VERSION_COMPATIBILITY: PY2+3 — **def [RunSteps](/recipes/recipe_modules/windows_sdk/examples/full.py#16)(api):** -[recipe_engine/recipe_modules/assertions]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/5226416ff445b80b55042d5e28d51b5da035f48d/README.recipes.md#recipe_modules-assertions -[recipe_engine/recipe_modules/buildbucket]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/5226416ff445b80b55042d5e28d51b5da035f48d/README.recipes.md#recipe_modules-buildbucket -[recipe_engine/recipe_modules/cipd]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/5226416ff445b80b55042d5e28d51b5da035f48d/README.recipes.md#recipe_modules-cipd -[recipe_engine/recipe_modules/commit_position]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/5226416ff445b80b55042d5e28d51b5da035f48d/README.recipes.md#recipe_modules-commit_position -[recipe_engine/recipe_modules/context]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/5226416ff445b80b55042d5e28d51b5da035f48d/README.recipes.md#recipe_modules-context -[recipe_engine/recipe_modules/cq]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/5226416ff445b80b55042d5e28d51b5da035f48d/README.recipes.md#recipe_modules-cq -[recipe_engine/recipe_modules/file]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/5226416ff445b80b55042d5e28d51b5da035f48d/README.recipes.md#recipe_modules-file -[recipe_engine/recipe_modules/json]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/5226416ff445b80b55042d5e28d51b5da035f48d/README.recipes.md#recipe_modules-json -[recipe_engine/recipe_modules/led]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/5226416ff445b80b55042d5e28d51b5da035f48d/README.recipes.md#recipe_modules-led -[recipe_engine/recipe_modules/milo]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/5226416ff445b80b55042d5e28d51b5da035f48d/README.recipes.md#recipe_modules-milo -[recipe_engine/recipe_modules/path]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/5226416ff445b80b55042d5e28d51b5da035f48d/README.recipes.md#recipe_modules-path -[recipe_engine/recipe_modules/platform]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/5226416ff445b80b55042d5e28d51b5da035f48d/README.recipes.md#recipe_modules-platform -[recipe_engine/recipe_modules/properties]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/5226416ff445b80b55042d5e28d51b5da035f48d/README.recipes.md#recipe_modules-properties -[recipe_engine/recipe_modules/python]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/5226416ff445b80b55042d5e28d51b5da035f48d/README.recipes.md#recipe_modules-python -[recipe_engine/recipe_modules/raw_io]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/5226416ff445b80b55042d5e28d51b5da035f48d/README.recipes.md#recipe_modules-raw_io -[recipe_engine/recipe_modules/resultdb]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/5226416ff445b80b55042d5e28d51b5da035f48d/README.recipes.md#recipe_modules-resultdb -[recipe_engine/recipe_modules/runtime]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/5226416ff445b80b55042d5e28d51b5da035f48d/README.recipes.md#recipe_modules-runtime -[recipe_engine/recipe_modules/step]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/5226416ff445b80b55042d5e28d51b5da035f48d/README.recipes.md#recipe_modules-step -[recipe_engine/recipe_modules/time]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/5226416ff445b80b55042d5e28d51b5da035f48d/README.recipes.md#recipe_modules-time -[recipe_engine/recipe_modules/url]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/5226416ff445b80b55042d5e28d51b5da035f48d/README.recipes.md#recipe_modules-url -[recipe_engine/recipe_modules/version]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/5226416ff445b80b55042d5e28d51b5da035f48d/README.recipes.md#recipe_modules-version -[recipe_engine/wkt/RecipeApi]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/5226416ff445b80b55042d5e28d51b5da035f48d/recipe_engine/recipe_api.py#886 +[recipe_engine/recipe_modules/assertions]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/8f92d0c510bcddd3c369a14d222ecc18d7c63783/README.recipes.md#recipe_modules-assertions +[recipe_engine/recipe_modules/buildbucket]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/8f92d0c510bcddd3c369a14d222ecc18d7c63783/README.recipes.md#recipe_modules-buildbucket +[recipe_engine/recipe_modules/cipd]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/8f92d0c510bcddd3c369a14d222ecc18d7c63783/README.recipes.md#recipe_modules-cipd +[recipe_engine/recipe_modules/commit_position]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/8f92d0c510bcddd3c369a14d222ecc18d7c63783/README.recipes.md#recipe_modules-commit_position +[recipe_engine/recipe_modules/context]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/8f92d0c510bcddd3c369a14d222ecc18d7c63783/README.recipes.md#recipe_modules-context +[recipe_engine/recipe_modules/cq]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/8f92d0c510bcddd3c369a14d222ecc18d7c63783/README.recipes.md#recipe_modules-cq +[recipe_engine/recipe_modules/file]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/8f92d0c510bcddd3c369a14d222ecc18d7c63783/README.recipes.md#recipe_modules-file +[recipe_engine/recipe_modules/json]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/8f92d0c510bcddd3c369a14d222ecc18d7c63783/README.recipes.md#recipe_modules-json +[recipe_engine/recipe_modules/led]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/8f92d0c510bcddd3c369a14d222ecc18d7c63783/README.recipes.md#recipe_modules-led +[recipe_engine/recipe_modules/milo]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/8f92d0c510bcddd3c369a14d222ecc18d7c63783/README.recipes.md#recipe_modules-milo +[recipe_engine/recipe_modules/path]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/8f92d0c510bcddd3c369a14d222ecc18d7c63783/README.recipes.md#recipe_modules-path +[recipe_engine/recipe_modules/platform]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/8f92d0c510bcddd3c369a14d222ecc18d7c63783/README.recipes.md#recipe_modules-platform +[recipe_engine/recipe_modules/properties]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/8f92d0c510bcddd3c369a14d222ecc18d7c63783/README.recipes.md#recipe_modules-properties +[recipe_engine/recipe_modules/python]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/8f92d0c510bcddd3c369a14d222ecc18d7c63783/README.recipes.md#recipe_modules-python +[recipe_engine/recipe_modules/raw_io]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/8f92d0c510bcddd3c369a14d222ecc18d7c63783/README.recipes.md#recipe_modules-raw_io +[recipe_engine/recipe_modules/resultdb]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/8f92d0c510bcddd3c369a14d222ecc18d7c63783/README.recipes.md#recipe_modules-resultdb +[recipe_engine/recipe_modules/runtime]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/8f92d0c510bcddd3c369a14d222ecc18d7c63783/README.recipes.md#recipe_modules-runtime +[recipe_engine/recipe_modules/step]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/8f92d0c510bcddd3c369a14d222ecc18d7c63783/README.recipes.md#recipe_modules-step +[recipe_engine/recipe_modules/time]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/8f92d0c510bcddd3c369a14d222ecc18d7c63783/README.recipes.md#recipe_modules-time +[recipe_engine/recipe_modules/url]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/8f92d0c510bcddd3c369a14d222ecc18d7c63783/README.recipes.md#recipe_modules-url +[recipe_engine/recipe_modules/version]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/8f92d0c510bcddd3c369a14d222ecc18d7c63783/README.recipes.md#recipe_modules-version +[recipe_engine/wkt/RecipeApi]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/8f92d0c510bcddd3c369a14d222ecc18d7c63783/recipe_engine/recipe_api.py#886 diff --git a/recipes/recipes.py b/recipes/recipes.py index 81b0bc6edd..7c534c224c 100755 --- a/recipes/recipes.py +++ b/recipes/recipes.py @@ -70,9 +70,12 @@ def parse(repo_root, recipes_cfg_path): recipes_path (str) - native path to where the recipes live inside of the current repo (i.e. the folder containing `recipes/` and/or `recipe_modules`) + py3_only (bool) - True if this repo has been marked as ONLY supporting + python3. """ with open(recipes_cfg_path, 'r') as fh: pb = json.load(fh) + py3_only = pb.get('py3_only', False) try: if pb['api_version'] != 2: @@ -85,7 +88,7 @@ def parse(repo_root, recipes_cfg_path): if not repo_name: repo_name = pb['project_id'] if repo_name == 'recipe_engine': - return None, pb.get('recipes_path', '') + return None, pb.get('recipes_path', ''), py3_only engine = pb['deps']['recipe_engine'] @@ -104,7 +107,7 @@ def parse(repo_root, recipes_cfg_path): recipes_path = os.path.join(repo_root, recipes_path.replace('/', os.path.sep)) - return EngineDep(**engine), recipes_path + return EngineDep(**engine), recipes_path, py3_only except KeyError as ex: raise MalformedRecipesCfg(str(ex), recipes_cfg_path) @@ -113,11 +116,8 @@ IS_WIN = sys.platform.startswith(('win', 'cygwin')) _BAT = '.bat' if IS_WIN else '' GIT = 'git' + _BAT -VPYTHON = ('vpython' + - ('3' if os.getenv('RECIPES_USE_PY3') == 'true' else '') + - _BAT) CIPD = 'cipd' + _BAT -REQUIRED_BINARIES = {GIT, VPYTHON, CIPD} +REQUIRED_BINARIES = {GIT, CIPD} def _is_executable(path): @@ -169,10 +169,14 @@ def parse_args(argv): def checkout_engine(engine_path, repo_root, recipes_cfg_path): - dep, recipes_path = parse(repo_root, recipes_cfg_path) + """Checks out the recipe_engine repo pinned in recipes.cfg. + + Returns the path to the recipe engine repo and the py3_only boolean. + """ + dep, recipes_path, py3_only = parse(repo_root, recipes_cfg_path) if dep is None: # we're running from the engine repo already! - return os.path.join(repo_root, recipes_path) + return os.path.join(repo_root, recipes_path), py3_only url = dep.url @@ -217,7 +221,7 @@ def checkout_engine(engine_path, repo_root, recipes_cfg_path): # or things will get squirrely. _git_check_call(['clean', '-qxf'], cwd=engine_path) - return engine_path + return engine_path, py3_only def main(): @@ -243,11 +247,16 @@ def main(): repo_root = os.path.abspath(repo_root).decode() recipes_cfg_path = os.path.join(repo_root, 'infra', 'config', 'recipes.cfg') args = ['--package', recipes_cfg_path] + args - engine_path = checkout_engine(engine_override, repo_root, recipes_cfg_path) + engine_path, py3_only = checkout_engine(engine_override, repo_root, recipes_cfg_path) + + using_py3 = py3_only or os.getenv('RECIPES_USE_PY3') == 'true' + vpython = ('vpython' + ('3' if using_py3 else '') + _BAT) + if not _is_on_path(vpython): + return 'Required binary is not found on PATH: %s' % vpython - argv = ( - [VPYTHON, '-u', - os.path.join(engine_path, 'recipe_engine', 'main.py')] + args) + argv = ([ + vpython, '-u', os.path.join(engine_path, 'recipe_engine', 'main.py'), + ] + args) if IS_WIN: # No real 'exec' on windows; set these signals to ignore so that they