From 7002fbedd73c4c240ea1e1593b1275b0df79c5d0 Mon Sep 17 00:00:00 2001 From: Zbynek Winkler Date: Thu, 14 Apr 2016 21:38:45 +0200 Subject: Ensure virtualenv activates. There are two changes: * remove quoting which causes virtuaenv not activate * check virtualenv actually activated If the quoting added in the fix in #8394 (4ff8d3ad9cea) kicks in, it causes virtualenv to fail to activate. For the common case it is no op: ```python >>> from pipes import quote >>> print quote('common/case') common/case ``` When the path actually needs quoting, this is what happens: ```python >>> print quote('test spaces') 'test spaces' >>> print quote('windows\\path') 'windows\\path' ``` Note the embedded quotes. Virtualenv in activate_this.py uses __file__ to build the path that should be added to PATH: ```python >>> print os.getcwd() C:\software\git >>> print os.path.abspath(quote('windows\\path')) C:\software\git\'windows\path' >>> ``` The constructed path is not valid. Adding it at the beginning of PATH has no effect. This issue affects any case when the call to `quote` kicks in. --- python/mach_bootstrap.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'python/mach_bootstrap.py') diff --git a/python/mach_bootstrap.py b/python/mach_bootstrap.py index 05b21c4fdfa..3960ba6f8e0 100644 --- a/python/mach_bootstrap.py +++ b/python/mach_bootstrap.py @@ -9,7 +9,6 @@ import platform import subprocess import sys from distutils.spawn import find_executable -from pipes import quote SEARCH_PATHS = [ os.path.join("python", "mach"), @@ -111,7 +110,11 @@ def _activate_virtualenv(topdir): except (subprocess.CalledProcessError, OSError): sys.exit("Python virtualenv failed to execute properly.") - execfile(activate_path, dict(__file__=quote(activate_path))) + execfile(activate_path, dict(__file__=activate_path)) + + python = find_executable("python") + if python is None or not python.startswith(virtualenv_path): + sys.exit("Python virtualenv failed to activate.") # TODO: Right now, we iteratively install all the requirements by invoking # `pip install` each time. If it were the case that there were conflicting -- cgit v1.2.3