Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(19)

Side by Side Diff: tools/find_depot_tools.py

Issue 734403002: Prototype for a client-side performance trybot script. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Review. Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | tools/try_perf.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # Copyright 2014 the V8 project 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.
5 """
6
7 import os
8 import sys
9
10
11 def directory_really_is_depot_tools(directory):
12 return os.path.isfile(os.path.join(directory, 'gclient.py'))
13
14
15 def add_depot_tools_to_path():
16 """Search for depot_tools and add it to sys.path."""
17 # First look if depot_tools is already in PYTHONPATH.
18 for i in sys.path:
19 if i.rstrip(os.sep).endswith('depot_tools'):
20 if directory_really_is_depot_tools(i):
21 return i
22
23 # Then look if depot_tools is in PATH, common case.
24 for i in os.environ['PATH'].split(os.pathsep):
25 if i.rstrip(os.sep).endswith('depot_tools'):
26 if directory_really_is_depot_tools(i):
27 sys.path.insert(0, 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 if directory_really_is_depot_tools(os.path.join(root_dir, 'depot_tools')):
34 i = os.path.join(root_dir, 'depot_tools')
35 sys.path.insert(0, i)
36 return i
37 previous_dir = root_dir
38 root_dir = os.path.dirname(root_dir)
39 print >> sys.stderr, 'Failed to find depot_tools'
40 return None
OLDNEW
« no previous file with comments | « no previous file | tools/try_perf.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698