Flutter Engine
The Flutter Engine
find_depot_tools.py
Go to the documentation of this file.
1# Copyright (c) 2011 The Chromium Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4"""Small utility function to find depot_tools and add it to the python path.
5Will throw an ImportError exception if depot_tools can't be found since it
6imports breakpad.
7"""
8
9from __future__ import print_function
10
11import os
12import sys
13
14def IsRealDepotTools(path):
15 return os.path.isfile(os.path.join(path, 'gclient.py'))
16
17
19 """Search for depot_tools and add it to sys.path."""
20 # First look if depot_tools is already in PYTHONPATH.
21 for i in sys.path:
22 if i.rstrip(os.sep).endswith('depot_tools') and IsRealDepotTools(i):
23 return i
24 # Then look if depot_tools is in PATH, common case.
25 for i in os.environ['PATH'].split(os.pathsep):
26 if IsRealDepotTools(i):
27 sys.path.append(i.rstrip(os.sep))
28 return i
29 # Rare case, it's not even in PATH, look upward up to root.
30 root_dir = os.path.dirname(os.path.abspath(__file__))
31 previous_dir = os.path.abspath(__file__)
32 while root_dir and root_dir != previous_dir:
33 i = os.path.join(root_dir, 'depot_tools')
34 if IsRealDepotTools(i):
35 sys.path.append(i)
36 return i
37 previous_dir = root_dir
38 root_dir = os.path.dirname(root_dir)
39 print('Failed to find depot_tools', file=sys.stderr)
40 return None
41
42
44
45# pylint: disable=W0611
46import breakpad
def IsRealDepotTools(path)
def print(*args, **kwargs)
Definition: run_tests.py:49