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

Side by Side Diff: scripts/common/env.py

Issue 1402253002: CrOS: Load Chromite pins from JSON. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Rebase (without pin JSON). Created 5 years, 2 months 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 | Annotate | Revision Log
« no previous file with comments | « scripts/common/cros_chromite.py ('k') | scripts/common/unittests/cros_chromite_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2015 The Chromium Authors. All rights reserved. 2 # Copyright 2015 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Implements a standard mechanism for Chrome Infra Python environment setup. 6 """Implements a standard mechanism for Chrome Infra Python environment setup.
7 7
8 This library provides a central location to define Chrome Infra environment 8 This library provides a central location to define Chrome Infra environment
9 setup. It also provides several faculties to install this environment. 9 setup. It also provides several faculties to install this environment.
10 10
(...skipping 28 matching lines...) Expand all
39 import traceback 39 import traceback
40 40
41 41
42 # Export for bootstrapping. 42 # Export for bootstrapping.
43 __all__ = [ 43 __all__ = [
44 'Install', 44 'Install',
45 'PythonPath', 45 'PythonPath',
46 ] 46 ]
47 47
48 48
49 # This is the path of the current "env" module. When "env" is run from
50 # command-line, this path is automatically appended, and should be stripped out
51 # of system path generation.
52 _env_module_path = os.path.abspath(os.path.dirname(__file__))
53
49 # Name of enviornment extension file to seek. 54 # Name of enviornment extension file to seek.
50 ENV_EXTENSION_NAME = 'environment.cfg.py' 55 ENV_EXTENSION_NAME = 'environment.cfg.py'
51 56
52 # Standard directories (based on this file's location in the <build> tree). 57 # Standard directories (based on this file's location in the <build> tree).
53 def path_if(*args): 58 def path_if(*args):
54 if not all(args): 59 if not all(args):
55 return None 60 return None
56 path = os.path.abspath(os.path.join(*args)) 61 path = os.path.abspath(os.path.join(*args))
57 return (path) if os.path.exists(path) else (None) 62 return (path) if os.path.exists(path) else (None)
58 63
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 sys.path = orig_sys_path 308 sys.path = orig_sys_path
304 SetPythonPathEnv(orig_pythonpath) 309 SetPythonPathEnv(orig_pythonpath)
305 310
306 311
307 def GetSysPythonPath(hermetic=True): 312 def GetSysPythonPath(hermetic=True):
308 """Returns (PythonPath): A path based on 'sys.path'. 313 """Returns (PythonPath): A path based on 'sys.path'.
309 314
310 Args: 315 Args:
311 hermetic (bool): If True, prune any non-system path. 316 hermetic (bool): If True, prune any non-system path.
312 """ 317 """
313 path = PythonPath.FromPaths(*sys.path) 318 sys_paths = [p for p in sys.path
319 if p != _env_module_path]
320 path = PythonPath.FromPaths(*sys_paths)
314 if hermetic: 321 if hermetic:
315 path = path.GetHermetic() 322 path = path.GetHermetic()
316 return path 323 return path
317 324
318 325
319 def GetEnvPythonPath(): 326 def GetEnvPythonPath():
320 """Returns (PythonPath): A path based on the PYTHONPATH environment variable. 327 """Returns (PythonPath): A path based on the PYTHONPATH environment variable.
321 """ 328 """
322 pythonpath = os.environ.get('PYTHONPATH') 329 pythonpath = os.environ.get('PYTHONPATH')
323 if not pythonpath: 330 if not pythonpath:
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 # Parse 437 # Parse
431 args = parser.parse_args() 438 args = parser.parse_args()
432 439
433 # Execute our subcommand function, which will return the exit code. 440 # Execute our subcommand function, which will return the exit code.
434 path = _InfraPathFromArgs(args) 441 path = _InfraPathFromArgs(args)
435 return args.func(args, path) 442 return args.func(args, path)
436 443
437 444
438 if __name__ == '__main__': 445 if __name__ == '__main__':
439 sys.exit(main()) 446 sys.exit(main())
OLDNEW
« no previous file with comments | « scripts/common/cros_chromite.py ('k') | scripts/common/unittests/cros_chromite_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698