Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2017 The LUCI Authors. All rights reserved. | 1 // Copyright 2017 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package vpython | 5 package vpython |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "os" | 8 "os" |
| 9 "os/exec" | 9 "os/exec" |
| 10 "os/signal" | 10 "os/signal" |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 59 | 59 |
| 60 // Create our virtual environment root directory. | 60 // Create our virtual environment root directory. |
| 61 err := venv.With(c, opts.EnvConfig, opts.WaitForEnv, func(c context.Cont ext, ve *venv.Env) error { | 61 err := venv.With(c, opts.EnvConfig, opts.WaitForEnv, func(c context.Cont ext, ve *venv.Env) error { |
| 62 // Build the augmented environment variables. | 62 // Build the augmented environment variables. |
| 63 e := opts.Environ | 63 e := opts.Environ |
| 64 if e.Len() == 0 { | 64 if e.Len() == 0 { |
| 65 // If no environment was supplied, use the system enviro nment. | 65 // If no environment was supplied, use the system enviro nment. |
| 66 e = environ.System() | 66 e = environ.System() |
| 67 } | 67 } |
| 68 | 68 |
| 69 // Remove PYTHONPATH and PYTHONHOME from the environment. This p revents them | |
| 70 // from being propagated to delegate processes (e.g., "vpython" script calls | |
| 71 // Python script, the "vpython" one uses the Interpreter's Isola tedCommand | |
| 72 // to isolate the initial run, but the delegate command blindly uses the | |
| 73 // environment that it's provided). | |
| 74 e.Remove("PYTHONPATH") | |
| 75 e.Remove("PYTHONHOME") | |
|
iannucci
2017/05/08 18:59:08
what about site path stuff? or do these cover that
dnj
2017/05/08 19:03:07
Adding PYTHONNOUSERSITE, which prevents this.
| |
| 76 | |
| 69 e.Set("VIRTUAL_ENV", ve.Root) // Set by VirtualEnv script. | 77 e.Set("VIRTUAL_ENV", ve.Root) // Set by VirtualEnv script. |
| 70 if ve.EnvironmentStampPath != "" { | 78 if ve.EnvironmentStampPath != "" { |
| 71 e.Set(EnvironmentStampPathENV, ve.EnvironmentStampPath) | 79 e.Set(EnvironmentStampPathENV, ve.EnvironmentStampPath) |
| 72 } | 80 } |
| 73 | 81 |
| 74 // Prefix PATH with the VirtualEnv "bin" directory. | 82 // Prefix PATH with the VirtualEnv "bin" directory. |
| 75 prefixPATH(e, ve.BinDir) | 83 prefixPATH(e, ve.BinDir) |
| 76 | 84 |
| 77 // Run our bootstrapped Python command. | 85 // Run our bootstrapped Python command. |
| 78 cmd := ve.Interpreter().IsolatedCommand(c, opts.Args...) | 86 cmd := ve.Interpreter().IsolatedCommand(c, opts.Args...) |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 147 components = append([]string(nil), components...) | 155 components = append([]string(nil), components...) |
| 148 | 156 |
| 149 // If there is a current PATH (likely), add that to the end. | 157 // If there is a current PATH (likely), add that to the end. |
| 150 cur, _ := env.Get("PATH") | 158 cur, _ := env.Get("PATH") |
| 151 if len(cur) > 0 { | 159 if len(cur) > 0 { |
| 152 components = append(components, cur) | 160 components = append(components, cur) |
| 153 } | 161 } |
| 154 | 162 |
| 155 env.Set("PATH", strings.Join(components, string(os.PathListSeparator))) | 163 env.Set("PATH", strings.Join(components, string(os.PathListSeparator))) |
| 156 } | 164 } |
| OLD | NEW |