diff options
author | Ravi Shankar <wafflespeanut@gmail.com> | 2016-09-01 16:56:18 +0530 |
---|---|---|
committer | Ravi Shankar <wafflespeanut@gmail.com> | 2016-09-01 17:00:18 +0530 |
commit | f83fe9e39b549fe6cd185be5c2e0ca6a9d86617b (patch) | |
tree | 46dd28301ed1651bb06c8042a3d4b82583194379 /python/mach_bootstrap.py | |
parent | c3ef836c09f0453a795a1c76f1daa4ed4fc05a2f (diff) | |
download | servo-f83fe9e39b549fe6cd185be5c2e0ca6a9d86617b.tar.gz servo-f83fe9e39b549fe6cd185be5c2e0ca6a9d86617b.zip |
Ensure that we get python and pip from virtualenv
Diffstat (limited to 'python/mach_bootstrap.py')
-rw-r--r-- | python/mach_bootstrap.py | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/python/mach_bootstrap.py b/python/mach_bootstrap.py index d63f66492d5..8a568e95df4 100644 --- a/python/mach_bootstrap.py +++ b/python/mach_bootstrap.py @@ -77,10 +77,10 @@ CATEGORIES = { } -def _get_exec(*names): +def _get_exec(names, is_valid_path=lambda _path: True): for name in names: path = find_executable(name) - if path is not None: + if path and is_valid_path(path): return path return None @@ -100,14 +100,15 @@ PIP_NAMES = ["pip-2.7", "pip2.7", "pip2", "pip"] def _activate_virtualenv(topdir): virtualenv_path = os.path.join(topdir, "python", "_virtualenv") - python = _get_exec(*PYTHON_NAMES) + check_exec_path = lambda path: path.startswith(virtualenv_path) + python = _get_exec(PYTHON_NAMES) if python is None: sys.exit("Python is not installed. Please install it prior to running mach.") script_dir = _get_virtualenv_script_dir() activate_path = os.path.join(virtualenv_path, script_dir, "activate_this.py") if not (os.path.exists(virtualenv_path) and os.path.exists(activate_path)): - virtualenv = _get_exec(*VIRTUALENV_NAMES) + virtualenv = _get_exec(VIRTUALENV_NAMES) if virtualenv is None: sys.exit("Python virtualenv is not installed. Please install it prior to running mach.") @@ -122,8 +123,8 @@ def _activate_virtualenv(topdir): execfile(activate_path, dict(__file__=activate_path)) - python = find_executable("python") - if python is None or not python.startswith(virtualenv_path): + python = _get_exec(PYTHON_NAMES, is_valid_path=check_exec_path) + if python is None: sys.exit("Python virtualenv failed to activate.") # TODO: Right now, we iteratively install all the requirements by invoking @@ -148,7 +149,7 @@ def _activate_virtualenv(topdir): except OSError: pass - pip = _get_exec(*PIP_NAMES) + pip = _get_exec(PIP_NAMES, is_valid_path=check_exec_path) if pip is None: sys.exit("Python pip is not installed. Please install it prior to running mach.") |