From 76b679fcf2128ed00ba7e196fd6015154f51a65a Mon Sep 17 00:00:00 2001 From: Gavin Mak Date: Fri, 27 Aug 2021 00:47:24 +0000 Subject: [PATCH] Add PYTHON_VERSION_COMPATIBILITY to gclient recipe module Bug: 1227140 Change-Id: I18ad289ffac1df5482a3d6a6e4484bd69a6d6929 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3123938 Commit-Queue: Gavin Mak Reviewed-by: Anthony Polito --- recipes/README.recipes.md | 40 +++++++++---------- recipes/recipe_modules/gclient/__init__.py | 2 + recipes/recipe_modules/gclient/api.py | 1 + .../recipe_modules/gclient/examples/full.py | 2 + recipes/recipe_modules/gclient/test_api.py | 2 +- .../dont have revision yet.json | 6 +-- .../no change, exception.json | 4 +- .../recipe_modules/gclient/tests/diff_deps.py | 2 + .../gclient/tests/patch_project.py | 2 + .../gclient/tests/sync_failure.py | 2 + 10 files changed, 37 insertions(+), 26 deletions(-) diff --git a/recipes/README.recipes.md b/recipes/README.recipes.md index e79c2127f..0c5a93639 100644 --- a/recipes/README.recipes.md +++ b/recipes/README.recipes.md @@ -6,7 +6,7 @@ * [bot_update](#recipe_modules-bot_update) (Python3 ✅) — Recipe module to ensure a checkout is consistent on a bot. * [cipd](#recipe_modules-cipd) — API for interacting with CIPD. * [depot_tools](#recipe_modules-depot_tools) (Python3 ✅) — The `depot_tools` module provides safe functions to access paths within the depot_tools repo. - * [gclient](#recipe_modules-gclient) + * [gclient](#recipe_modules-gclient) (Python3 ✅) * [gerrit](#recipe_modules-gerrit) (Python3 ✅) * [git](#recipe_modules-git) * [git_cl](#recipe_modules-git_cl) (Python3 ✅) @@ -25,10 +25,10 @@ * [cipd:examples/platform_suffix](#recipes-cipd_examples_platform_suffix) * [depot_tools:examples/full](#recipes-depot_tools_examples_full) (Python3 ✅) * [fetch_end_to_end_test](#recipes-fetch_end_to_end_test) - * [gclient:examples/full](#recipes-gclient_examples_full) - * [gclient:tests/diff_deps](#recipes-gclient_tests_diff_deps) - * [gclient:tests/patch_project](#recipes-gclient_tests_patch_project) - * [gclient:tests/sync_failure](#recipes-gclient_tests_sync_failure) + * [gclient:examples/full](#recipes-gclient_examples_full) (Python3 ✅) + * [gclient:tests/diff_deps](#recipes-gclient_tests_diff_deps) (Python3 ✅) + * [gclient:tests/patch_project](#recipes-gclient_tests_patch_project) (Python3 ✅) + * [gclient:tests/sync_failure](#recipes-gclient_tests_sync_failure) (Python3 ✅) * [gerrit:examples/full](#recipes-gerrit_examples_full) (Python3 ✅) * [git:examples/full](#recipes-git_examples_full) * [git_cl:examples/full](#recipes-git_cl_examples_full) (Python3 ✅) @@ -279,13 +279,13 @@ Returns (Path): The "depot_tools" root directory.   **@property**
— **def [upload\_to\_google\_storage\_path](/recipes/recipe_modules/depot_tools/api.py#17)(self):** ### *recipe_modules* / [gclient](/recipes/recipe_modules/gclient) -[DEPS](/recipes/recipe_modules/gclient/__init__.py#1): [git](#recipe_modules-git), [gitiles](#recipe_modules-gitiles), [tryserver](#recipe_modules-tryserver), [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/json][recipe_engine/recipe_modules/json], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/python][recipe_engine/recipe_modules/python], [recipe\_engine/raw\_io][recipe_engine/recipe_modules/raw_io], [recipe\_engine/step][recipe_engine/recipe_modules/step] +[DEPS](/recipes/recipe_modules/gclient/__init__.py#3): [git](#recipe_modules-git), [gitiles](#recipe_modules-gitiles), [tryserver](#recipe_modules-tryserver), [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/json][recipe_engine/recipe_modules/json], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/python][recipe_engine/recipe_modules/python], [recipe\_engine/raw\_io][recipe_engine/recipe_modules/raw_io], [recipe\_engine/step][recipe_engine/recipe_modules/step] -PYTHON_VERSION_COMPATIBILITY: PY2 +PYTHON_VERSION_COMPATIBILITY: PY2+3 #### **class [GclientApi](/recipes/recipe_modules/gclient/api.py#77)([RecipeApi][recipe_engine/wkt/RecipeApi]):** -  **@property**
— **def [DepsDiffException](/recipes/recipe_modules/gclient/api.py#440)(self):** +  **@property**
— **def [DepsDiffException](/recipes/recipe_modules/gclient/api.py#441)(self):** — **def [\_\_call\_\_](/recipes/recipe_modules/gclient/api.py#87)(self, name, cmd, infra_step=True, \*\*kwargs):** @@ -1106,32 +1106,32 @@ PYTHON_VERSION_COMPATIBILITY: PY2 — **def [RunSteps](/recipes/recipes/fetch_end_to_end_test.py#16)(api):** ### *recipes* / [gclient:examples/full](/recipes/recipe_modules/gclient/examples/full.py) -[DEPS](/recipes/recipe_modules/gclient/examples/full.py#5): [gclient](#recipe_modules-gclient), [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/step][recipe_engine/recipe_modules/step] +[DEPS](/recipes/recipe_modules/gclient/examples/full.py#7): [gclient](#recipe_modules-gclient), [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/step][recipe_engine/recipe_modules/step] -PYTHON_VERSION_COMPATIBILITY: PY2 +PYTHON_VERSION_COMPATIBILITY: PY2+3 -— **def [RunSteps](/recipes/recipe_modules/gclient/examples/full.py#64)(api):** +— **def [RunSteps](/recipes/recipe_modules/gclient/examples/full.py#66)(api):** ### *recipes* / [gclient:tests/diff\_deps](/recipes/recipe_modules/gclient/tests/diff_deps.py) -[DEPS](/recipes/recipe_modules/gclient/tests/diff_deps.py#7): [gclient](#recipe_modules-gclient), [recipe\_engine/assertions][recipe_engine/recipe_modules/assertions], [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/raw\_io][recipe_engine/recipe_modules/raw_io] +[DEPS](/recipes/recipe_modules/gclient/tests/diff_deps.py#9): [gclient](#recipe_modules-gclient), [recipe\_engine/assertions][recipe_engine/recipe_modules/assertions], [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/raw\_io][recipe_engine/recipe_modules/raw_io] -PYTHON_VERSION_COMPATIBILITY: PY2 +PYTHON_VERSION_COMPATIBILITY: PY2+3 -— **def [RunSteps](/recipes/recipe_modules/gclient/tests/diff_deps.py#18)(api):** +— **def [RunSteps](/recipes/recipe_modules/gclient/tests/diff_deps.py#20)(api):** ### *recipes* / [gclient:tests/patch\_project](/recipes/recipe_modules/gclient/tests/patch_project.py) -[DEPS](/recipes/recipe_modules/gclient/tests/patch_project.py#9): [gclient](#recipe_modules-gclient), [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/properties][recipe_engine/recipe_modules/properties] +[DEPS](/recipes/recipe_modules/gclient/tests/patch_project.py#11): [gclient](#recipe_modules-gclient), [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/properties][recipe_engine/recipe_modules/properties] -PYTHON_VERSION_COMPATIBILITY: PY2 +PYTHON_VERSION_COMPATIBILITY: PY2+3 -— **def [RunSteps](/recipes/recipe_modules/gclient/tests/patch_project.py#18)(api):** +— **def [RunSteps](/recipes/recipe_modules/gclient/tests/patch_project.py#20)(api):** ### *recipes* / [gclient:tests/sync\_failure](/recipes/recipe_modules/gclient/tests/sync_failure.py) -[DEPS](/recipes/recipe_modules/gclient/tests/sync_failure.py#7): [gclient](#recipe_modules-gclient), [recipe\_engine/path][recipe_engine/recipe_modules/path] +[DEPS](/recipes/recipe_modules/gclient/tests/sync_failure.py#9): [gclient](#recipe_modules-gclient), [recipe\_engine/path][recipe_engine/recipe_modules/path] -PYTHON_VERSION_COMPATIBILITY: PY2 +PYTHON_VERSION_COMPATIBILITY: PY2+3 -— **def [RunSteps](/recipes/recipe_modules/gclient/tests/sync_failure.py#13)(api):** +— **def [RunSteps](/recipes/recipe_modules/gclient/tests/sync_failure.py#15)(api):** ### *recipes* / [gerrit:examples/full](/recipes/recipe_modules/gerrit/examples/full.py) [DEPS](/recipes/recipe_modules/gerrit/examples/full.py#7): [gerrit](#recipe_modules-gerrit), [recipe\_engine/step][recipe_engine/recipe_modules/step] diff --git a/recipes/recipe_modules/gclient/__init__.py b/recipes/recipe_modules/gclient/__init__.py index 5b9781867..cf3b912fb 100644 --- a/recipes/recipe_modules/gclient/__init__.py +++ b/recipes/recipe_modules/gclient/__init__.py @@ -1,3 +1,5 @@ +PYTHON_VERSION_COMPATIBILITY = 'PY2+3' + DEPS = [ 'git', 'gitiles', diff --git a/recipes/recipe_modules/gclient/api.py b/recipes/recipe_modules/gclient/api.py index ff7d8c16e..fa7971505 100644 --- a/recipes/recipe_modules/gclient/api.py +++ b/recipes/recipe_modules/gclient/api.py @@ -406,6 +406,7 @@ class GclientApi(recipe_api.RecipeApi): # gclient recurse prepends a number and a > to each line # Let's take that out for line in step_result.stdout.strip().splitlines(): + line = line.decode('utf-8') if 'fatal: bad object' in line: msg = "Couldn't checkout previous ref: %s" % line step_result.presentation.logs['DepsDiffException'] = msg diff --git a/recipes/recipe_modules/gclient/examples/full.py b/recipes/recipe_modules/gclient/examples/full.py index af77f1250..f0fa9f540 100644 --- a/recipes/recipe_modules/gclient/examples/full.py +++ b/recipes/recipe_modules/gclient/examples/full.py @@ -2,6 +2,8 @@ # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. +PYTHON_VERSION_COMPATIBILITY = 'PY2+3' + DEPS = [ 'gclient', 'recipe_engine/buildbucket', diff --git a/recipes/recipe_modules/gclient/test_api.py b/recipes/recipe_modules/gclient/test_api.py index 663c01e50..44c3b3ef3 100644 --- a/recipes/recipe_modules/gclient/test_api.py +++ b/recipes/recipe_modules/gclient/test_api.py @@ -32,5 +32,5 @@ class GclientTestApi(recipe_test_api.RecipeTestApi): @staticmethod def gen_revision(project): """Hash project to bogus deterministic revision values.""" - h = hashlib.sha1(project) + h = hashlib.sha1(project.encode('utf-8')) return h.hexdigest() diff --git a/recipes/recipe_modules/gclient/tests/diff_deps.expected/dont have revision yet.json b/recipes/recipe_modules/gclient/tests/diff_deps.expected/dont have revision yet.json index b669f4dd2..b23667eee 100644 --- a/recipes/recipe_modules/gclient/tests/diff_deps.expected/dont have revision yet.json +++ b/recipes/recipe_modules/gclient/tests/diff_deps.expected/dont have revision yet.json @@ -62,16 +62,16 @@ "The recipe has crashed at point 'Uncaught exception'!", "", "Traceback (most recent call last):", - " File \"RECIPE_REPO[depot_tools]/recipes/recipe_modules/gclient/tests/diff_deps.py\", line 33, in RunSteps", + " File \"RECIPE_REPO[depot_tools]/recipes/recipe_modules/gclient/tests/diff_deps.py\", line 35, in RunSteps", " affected_files = api.gclient.diff_deps(api.path['cache'])", - " File \"RECIPE_REPO[depot_tools]/recipes/recipe_modules/gclient/api.py\", line 412, in diff_deps", + " File \"RECIPE_REPO[depot_tools]/recipes/recipe_modules/gclient/api.py\", line 413, in diff_deps", " raise self.DepsDiffException(msg)", "DepsDiffException: Couldn't checkout previous ref: fatal: bad object abcdef1234567890" ] }, { "failure": { - "humanReason": "Uncaught Exception: DepsDiffException(\"Couldn't checkout previous ref: fatal: bad object abcdef1234567890\",)" + "humanReason": "Uncaught Exception: DepsDiffException(u\"Couldn't checkout previous ref: fatal: bad object abcdef1234567890\",)" }, "name": "$result" } diff --git a/recipes/recipe_modules/gclient/tests/diff_deps.expected/no change, exception.json b/recipes/recipe_modules/gclient/tests/diff_deps.expected/no change, exception.json index 5ffbb4754..fffbe0fb5 100644 --- a/recipes/recipe_modules/gclient/tests/diff_deps.expected/no change, exception.json +++ b/recipes/recipe_modules/gclient/tests/diff_deps.expected/no change, exception.json @@ -61,9 +61,9 @@ "The recipe has crashed at point 'Uncaught exception'!", "", "Traceback (most recent call last):", - " File \"RECIPE_REPO[depot_tools]/recipes/recipe_modules/gclient/tests/diff_deps.py\", line 33, in RunSteps", + " File \"RECIPE_REPO[depot_tools]/recipes/recipe_modules/gclient/tests/diff_deps.py\", line 35, in RunSteps", " affected_files = api.gclient.diff_deps(api.path['cache'])", - " File \"RECIPE_REPO[depot_tools]/recipes/recipe_modules/gclient/api.py\", line 428, in diff_deps", + " File \"RECIPE_REPO[depot_tools]/recipes/recipe_modules/gclient/api.py\", line 429, in diff_deps", " raise self.DepsDiffException(msg)", "DepsDiffException: Unexpected result: autoroll diff found 0 files changed" ] diff --git a/recipes/recipe_modules/gclient/tests/diff_deps.py b/recipes/recipe_modules/gclient/tests/diff_deps.py index bc31434f2..ce0fb2a9f 100644 --- a/recipes/recipe_modules/gclient/tests/diff_deps.py +++ b/recipes/recipe_modules/gclient/tests/diff_deps.py @@ -4,6 +4,8 @@ from recipe_engine import post_process +PYTHON_VERSION_COMPATIBILITY = 'PY2+3' + DEPS = [ 'recipe_engine/assertions', 'recipe_engine/buildbucket', diff --git a/recipes/recipe_modules/gclient/tests/patch_project.py b/recipes/recipe_modules/gclient/tests/patch_project.py index 55b2fbb16..02a41af49 100644 --- a/recipes/recipe_modules/gclient/tests/patch_project.py +++ b/recipes/recipe_modules/gclient/tests/patch_project.py @@ -6,6 +6,8 @@ from recipe_engine import post_process from recipe_engine import recipe_api +PYTHON_VERSION_COMPATIBILITY = 'PY2+3' + DEPS = [ 'recipe_engine/buildbucket', 'recipe_engine/path', diff --git a/recipes/recipe_modules/gclient/tests/sync_failure.py b/recipes/recipe_modules/gclient/tests/sync_failure.py index 4867dcb28..df0d7f2b0 100644 --- a/recipes/recipe_modules/gclient/tests/sync_failure.py +++ b/recipes/recipe_modules/gclient/tests/sync_failure.py @@ -4,6 +4,8 @@ from recipe_engine import post_process +PYTHON_VERSION_COMPATIBILITY = 'PY2+3' + DEPS = [ 'recipe_engine/path',