5"""Small utility function to find depot_tools and add it to the python path.
7Will throw an ImportError exception if depot_tools can't be found since it
10This can also be used as a standalone script to print out the depot_tools
20SRC = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
24 expanded_path = os.path.expanduser(path)
25 return os.path.isfile(os.path.join(expanded_path,
'gclient.py'))
29 """Search for depot_tools and add it to sys.path."""
31 deps_depot_tools = os.path.join(SRC,
'third_party',
'depot_tools')
35 sys.path.insert(0, deps_depot_tools)
36 return deps_depot_tools
43 for i
in os.environ[
'PATH'].split(os.pathsep):
45 sys.path.append(i.rstrip(os.sep))
48 root_dir = os.path.dirname(os.path.abspath(__file__))
49 previous_dir = os.path.abspath(__file__)
50 while root_dir
and root_dir != previous_dir:
51 i = os.path.join(root_dir,
'depot_tools')
55 previous_dir = root_dir
56 root_dir = os.path.dirname(root_dir)
57 print(
'Failed to find depot_tools', file=sys.stderr)
67 if DEPOT_TOOLS_PATH
is None:
69 print(DEPOT_TOOLS_PATH)
73if __name__ ==
'__main__':
def print(*args, **kwargs)