Bug 1638780 - Don't import `virtualenv` unless necessary in `mach` commands r=froydnj

The module `distutils.sysconfig` isn't installed by default on Ubuntu -- the package `python3-distutils` exposes it. That's fine, except we unconditionally import it in `virtualenv.py`, which gets up indirectly being imported whenever you run any `mach` command, which will cause `bootstrap` to break before it even has the chance to install it.

`python3-pip` seems to rely on `python3-distutils` being installed so `bootstrap` will install it, so all we need to do is make sure it doesn't import `virtualenv` in any circumstance unless it's necessary (when surfacing an error in the module would be appropriate).

Differential Revision: https://phabricator.services.mozilla.com/D75833
This commit is contained in:
Ricky Stewart 2020-05-19 12:07:47 +00:00
Родитель 8ddc16d1ad
Коммит 57d020b2e6
1 изменённых файлов: 2 добавлений и 1 удалений

Просмотреть файл

@ -42,7 +42,6 @@ from .util import (
memoize,
memoized_property,
)
from .virtualenv import VirtualenvManager
def ancestors(path):
@ -273,6 +272,8 @@ class MozbuildObject(ProcessExecutionMixin):
@property
def virtualenv_manager(self):
from .virtualenv import VirtualenvManager
if self._virtualenv_manager is None:
name = "init"
if six.PY3: