Make tools/run_hooks.py work when depot_tools is not in PATH It should be possible to create and build from a Mojo checkout even when depot_tools is not in the PATH, even though many common development workflows require it. This teaches tools/run_hooks.py to add a default depot_tools location to the PATH that hooks run in so that a jiri checkout can execute hooks without PATH modifications. R=kulakowski@chromium.org, lanechr@google.com, viettrungluu@chromium.org Review URL: https://codereview.chromium.org/1760353002 .
diff --git a/tools/run_hooks.py b/tools/run_hooks.py index 478391b..52e27a0 100755 --- a/tools/run_hooks.py +++ b/tools/run_hooks.py
@@ -23,11 +23,18 @@ with open(deps_path) as deps_contents: d = deps_contents.read() exec(d, scope) + env = os.environ + # Some hooks expect depot_tools to be in the PATH already so add the default + # location of depot_tools in a standard checkout to the environment the hooks + # run in. + default_depot_tools_path = os.path.abspath(os.path.join(gclient_path, + "depot_tools")) + env["PATH"] += os.pathsep + default_depot_tools_path for hook in scope["hooks"]: name = hook["name"] print "________ running '%s' in '%s'" % (" ".join(hook["action"]), gclient_path) - subprocess.check_call(hook["action"], cwd=gclient_path) + subprocess.check_call(hook["action"], cwd=gclient_path, env=env) print return 0