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

Side by Side Diff: go/env.py

Issue 2089403002: infra/go: Stop extra evaluation of env.py output. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Created 4 years, 6 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
« no previous file with comments | « no previous file | no next file » | 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 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 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 """Can be used to point environment variable to hermetic Go toolset. 6 """Can be used to point environment variable to hermetic Go toolset.
7 7
8 Usage (on linux and mac): 8 Usage (on linux and mac):
9 $ eval `./env.py` 9 $ eval `./env.py`
10 $ go version 10 $ go version
11 11
12 Or it can be used to wrap a command: 12 Or it can be used to wrap a command:
13 13
14 $ ./env.py go version 14 $ ./env.py go version
15 """ 15 """
16 16
17 assert __name__ == '__main__' 17 assert __name__ == '__main__'
18 18
19 import imp 19 import imp
20 import os 20 import os
21 import pipes
21 import subprocess 22 import subprocess
22 import sys 23 import sys
23 24
24 # Do not want to mess with sys.path, load the module directly. 25 # Do not want to mess with sys.path, load the module directly.
25 bootstrap = imp.load_source( 26 bootstrap = imp.load_source(
26 'bootstrap', os.path.join(os.path.dirname(__file__), 'bootstrap.py')) 27 'bootstrap', os.path.join(os.path.dirname(__file__), 'bootstrap.py'))
27 28
28 old = os.environ.copy() 29 old = os.environ.copy()
29 new = bootstrap.prepare_go_environ() 30 new = bootstrap.prepare_go_environ()
30 31
31 if len(sys.argv) == 1: 32 if len(sys.argv) == 1:
32 for key, value in sorted(new.iteritems()): 33 for key, value in sorted(new.iteritems()):
33 if old.get(key) != value: 34 if old.get(key) != value:
34 print 'export %s="%s"' % (key, value) 35 print 'export %s=%s' % (key, pipes.quote(value))
35 else: 36 else:
36 exe = sys.argv[1] 37 exe = sys.argv[1]
37 if exe == 'python': 38 if exe == 'python':
38 exe = sys.executable 39 exe = sys.executable
39 else: 40 else:
40 # Help Windows to find the executable in new PATH, do it only when 41 # Help Windows to find the executable in new PATH, do it only when
41 # executable is referenced by name (and not by path). 42 # executable is referenced by name (and not by path).
42 if os.sep not in exe: 43 if os.sep not in exe:
43 exe = bootstrap.find_executable(exe, [bootstrap.WORKSPACE]) 44 exe = bootstrap.find_executable(exe, [bootstrap.WORKSPACE])
44 sys.exit(subprocess.call([exe] + sys.argv[2:], env=new)) 45 sys.exit(subprocess.call([exe] + sys.argv[2:], env=new))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698