testing: prevent double virtualenv activation
authorGregory Szorc <gps@mozilla.com>
Sat, 24 Jan 2015 19:42:03 -0800
changeset 360256 17f4091a1f7b876e4d3a4f50ef06e3886ba80e03
parent 360255 88e99df69400b7a6cbe4b1cb2f947c5dd239ba54
child 360257 1188bab9b7cc8e7d96ae6840e21b3429bd517fd7
push id16998
push userrwood@mozilla.com
push dateMon, 02 May 2016 19:42:03 +0000
testing: prevent double virtualenv activation The bootstrap code was potentially activating a virtualenv on top of itself. This results in the virtualenv's bin directory always being first in PATH. This threw off hg binary detection when running under --with-hg. Prevent double virtualenv activation.
mozreview
pulse
--- a/mozreview
+++ b/mozreview
@@ -4,19 +4,20 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import os
 import sys
 
 HERE = os.path.abspath(os.path.dirname(__file__))
 
 def main(args):
-    activate = os.path.join(HERE, 'venv', 'bin', 'activate_this.py')
-    execfile(activate, dict(__file__=activate))
-    sys.executable = os.path.join(HERE, 'venv', 'bin', 'python')
+    if 'VIRTUAL_ENV' not in os.environ:
+        activate = os.path.join(HERE, 'venv', 'bin', 'activate_this.py')
+        execfile(activate, dict(__file__=activate))
+        sys.executable = os.path.join(HERE, 'venv', 'bin', 'python')
 
     sys.path.insert(0, os.path.join(HERE, 'testing'))
 
     from mach.main import Mach
 
     m = Mach(os.getcwd())
 
     m.define_category('mozreview', 'MozReview',
--- a/pulse
+++ b/pulse
@@ -4,19 +4,20 @@
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
 import os
 import sys
 
 HERE = os.path.abspath(os.path.dirname(__file__))
 
 def main(args):
-    activate = os.path.join(HERE, 'venv', 'bin', 'activate_this.py')
-    execfile(activate, dict(__file__=activate))
-    sys.executable = os.path.join(HERE, 'venv', 'bin', 'python')
+    if 'VIRTUAL_ENV' not in os.environ:
+        activate = os.path.join(HERE, 'venv', 'bin', 'activate_this.py')
+        execfile(activate, dict(__file__=activate))
+        sys.executable = os.path.join(HERE, 'venv', 'bin', 'python')
 
     sys.path.insert(0, os.path.join(HERE, 'testing'))
 
     from mach.main import Mach
 
     m = Mach(os.getcwd())
 
     m.define_category('pulse', 'Pulse',