vpython: Forcefully clear PYTHON* environment.

Forcefully remove PYTHONPATH and PYTHONHOME from the environment of the
executed Python processes.

This prevents a situation where "vpython" runs an isolated Python
intepreter, but that Python interpreter runs a subcommand sans isolation
flags that then uses the propagated PYTHON* environment.

BUG=None
TEST=None
R=iannucci@chromium.org

Review-Url: https://codereview.chromium.org/2867843002
diff --git a/vpython/run.go b/vpython/run.go
index b817f1c..c8b7038 100644
--- a/vpython/run.go
+++ b/vpython/run.go
@@ -66,6 +66,19 @@
 			e = environ.System()
 		}
 
+		// Remove PYTHONPATH and PYTHONHOME from the environment. This prevents them
+		// from being propagated to delegate processes (e.g., "vpython" script calls
+		// Python script, the "vpython" one uses the Interpreter's IsolatedCommand
+		// to isolate the initial run, but the delegate command blindly uses the
+		// environment that it's provided).
+		//
+		// Also set PYTHONNOUSERSITE, which prevents a user's "site" configuration
+		// from influencing Python startup. The system "site" should already be
+		// ignored b/c we're using the VirtualEnv Python interpreter.
+		e.Remove("PYTHONPATH")
+		e.Remove("PYTHONHOME")
+		e.Set("PYTHONNOUSERSITE", "1")
+
 		e.Set("VIRTUAL_ENV", ve.Root) // Set by VirtualEnv script.
 		if ve.EnvironmentStampPath != "" {
 			e.Set(EnvironmentStampPathENV, ve.EnvironmentStampPath)