Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions | Variables
find_depot_tools Namespace Reference

Functions

 IsRealDepotTools (path)
 
 add_depot_tools_to_path ()
 
 main ()
 

Variables

 SRC = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))
 
 DEPOT_TOOLS_PATH = add_depot_tools_to_path()
 

Detailed Description

Small utility function to find depot_tools and add it to the python path.

Will throw an ImportError exception if depot_tools can't be found since it
imports breakpad.

This can also be used as a standalone script to print out the depot_tools
directory location.
Small utility function to find depot_tools and add it to the python path.
Will throw an ImportError exception if depot_tools can't be found since it
imports breakpad.

Function Documentation

◆ add_depot_tools_to_path()

find_depot_tools.add_depot_tools_to_path ( )
Search for depot_tools and add it to sys.path.

Definition at line 28 of file find_depot_tools.py.

28def add_depot_tools_to_path():
29 """Search for depot_tools and add it to sys.path."""
30 # First, check if we have a DEPS'd in "depot_tools".
31 deps_depot_tools = os.path.join(SRC, 'third_party', 'depot_tools')
32 if IsRealDepotTools(deps_depot_tools):
33 # Put the pinned version at the start of the sys.path, in case there
34 # are other non-pinned versions already on the sys.path.
35 sys.path.insert(0, deps_depot_tools)
36 return deps_depot_tools
37
38 # Then look if depot_tools is already in PYTHONPATH.
39 for i in sys.path:
40 if i.rstrip(os.sep).endswith('depot_tools') and IsRealDepotTools(i):
41 return i
42 # Then look if depot_tools is in PATH, common case.
43 for i in os.environ['PATH'].split(os.pathsep):
44 if IsRealDepotTools(i):
45 sys.path.append(i.rstrip(os.sep))
46 return i
47 # Rare case, it's not even in PATH, look upward up to root.
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')
52 if IsRealDepotTools(i):
53 sys.path.append(i)
54 return i
55 previous_dir = root_dir
56 root_dir = os.path.dirname(root_dir)
57 print('Failed to find depot_tools', file=sys.stderr)
58 return None
59
void print(void *str)
Definition bridge.cpp:126

◆ IsRealDepotTools()

find_depot_tools.IsRealDepotTools (   path)

Definition at line 23 of file find_depot_tools.py.

23def IsRealDepotTools(path):
24 expanded_path = os.path.expanduser(path)
25 return os.path.isfile(os.path.join(expanded_path, 'gclient.py'))
26
27

◆ main()

find_depot_tools.main ( )

Definition at line 66 of file find_depot_tools.py.

66def main():
67 if DEPOT_TOOLS_PATH is None:
68 return 1
69 print(DEPOT_TOOLS_PATH)
70 return 0
71
72
Definition main.py:1

Variable Documentation

◆ DEPOT_TOOLS_PATH

find_depot_tools.DEPOT_TOOLS_PATH = add_depot_tools_to_path()

Definition at line 60 of file find_depot_tools.py.

◆ SRC

find_depot_tools.SRC = os.path.abspath(os.path.join(os.path.dirname(__file__), os.pardir))

Definition at line 20 of file find_depot_tools.py.