From 7d7477fe718a2fbb94cae67dddbbeaf79cd7de26 Mon Sep 17 00:00:00 2001 From: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com> Date: Fri, 9 Oct 2020 14:51:03 -0600 Subject: [PATCH] chore(python): use 'setup.py' to detect repo root Closes #792 --- synthtool/gcp/templates/python_samples/noxfile.py.j2 | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/synthtool/gcp/templates/python_samples/noxfile.py.j2 b/synthtool/gcp/templates/python_samples/noxfile.py.j2 index ba55d7ce5..01686e4a0 100644 --- a/synthtool/gcp/templates/python_samples/noxfile.py.j2 +++ b/synthtool/gcp/templates/python_samples/noxfile.py.j2 @@ -201,6 +201,11 @@ def _get_repo_root(): break if Path(p / ".git").exists(): return str(p) + # .git is not available in repos cloned via Cloud Build + # setup.py is always in the library's root, so use that instead + # https://github.com/googleapis/synthtool/issues/792 + if Path(p / "setup.py").exists(): + return str(p) p = p.parent raise Exception("Unable to detect repository root.")