aboutsummaryrefslogtreecommitdiffstats
path: root/python/mach_bootstrap.py
diff options
context:
space:
mode:
authorTheGoddessInari <thegoddessinari@gmail.com>2019-03-25 21:33:28 -0700
committerJosh Matthews <josh@joshmatthews.net>2019-04-01 11:15:21 -0400
commit44162ceafbb46430d1f5fe59f59b95953f3353d9 (patch)
treee666524ed365e8e8ee351d6ac0dff8d64a1fedde /python/mach_bootstrap.py
parent9de37816783b36f7d8c3d12d1c0b2fafe9767543 (diff)
downloadservo-44162ceafbb46430d1f5fe59f59b95953f3353d9.tar.gz
servo-44162ceafbb46430d1f5fe59f59b95953f3353d9.zip
Don't assume the user's environment in mach_bootstrap.
On Windows with multiple Pythons installed, this was causing python2.7 to bootstrap a 3.7 virtualenv that it couldn't make use of. PIP_NAMES wasn't used at all, and VIRTUALENV_NAMES ends up being unused now.
Diffstat (limited to 'python/mach_bootstrap.py')
-rw-r--r--python/mach_bootstrap.py19
1 files changed, 7 insertions, 12 deletions
diff --git a/python/mach_bootstrap.py b/python/mach_bootstrap.py
index 9a2a79c6d6a..aded4c0a0e9 100644
--- a/python/mach_bootstrap.py
+++ b/python/mach_bootstrap.py
@@ -78,14 +78,7 @@ CATEGORIES = {
# Possible names of executables
# NOTE: Windows Python doesn't provide versioned executables, so we must use
# the plain names. On MSYS, we still use Windows Python.
-if sys.platform in ['msys', 'win32']:
- PYTHON_NAMES = ["python"]
- VIRTUALENV_NAMES = ["virtualenv"]
- PIP_NAMES = ["pip"]
-else:
- PYTHON_NAMES = ["python-2.7", "python2.7", "python2", "python"]
- VIRTUALENV_NAMES = ["virtualenv-2.7", "virtualenv2.7", "virtualenv2", "virtualenv"]
- PIP_NAMES = ["pip-2.7", "pip2.7", "pip2", "pip"]
+PYTHON_NAMES = ["python-2.7", "python2.7", "python2", "python"]
def _get_exec_path(names, is_valid_path=lambda _path: True):
@@ -154,7 +147,7 @@ def wptserve_path(is_firefox, topdir, *paths):
def _activate_virtualenv(topdir, is_firefox):
virtualenv_path = os.path.join(topdir, "python", "_virtualenv")
check_exec_path = lambda path: path.startswith(virtualenv_path)
- python = _get_exec_path(PYTHON_NAMES) # If there was no python, mach wouldn't have run at all!
+ python = sys.executable # If there was no python, mach wouldn't have run at all!
if not python:
sys.exit('Failed to find python executable for starting virtualenv.')
@@ -162,11 +155,13 @@ def _activate_virtualenv(topdir, is_firefox):
activate_path = os.path.join(virtualenv_path, script_dir, "activate_this.py")
need_pip_upgrade = False
if not (os.path.exists(virtualenv_path) and os.path.exists(activate_path)):
- virtualenv = _get_exec_path(VIRTUALENV_NAMES)
- if not virtualenv:
+ import imp
+ try:
+ imp.find_module('virtualenv')
+ except ImportError:
sys.exit("Python virtualenv is not installed. Please install it prior to running mach.")
- _process_exec([virtualenv, "-p", python, "--system-site-packages", virtualenv_path])
+ _process_exec([python, "-m", "virtualenv", "-p", python, "--system-site-packages", virtualenv_path])
# We want to upgrade pip when virtualenv created for the first time
need_pip_upgrade = True