Skip to content

Commit

Permalink
Bug 1743033 - Avoid creating mach virtualenv when running confgure st…
Browse files Browse the repository at this point in the history
…andalone. r=mhentges

Differential Revision: https://phabricator.services.mozilla.com/D132190
  • Loading branch information
glandium committed Nov 26, 2021
1 parent 70ae321 commit 99bfeba
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
22 changes: 16 additions & 6 deletions configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,17 @@
sys.path.insert(0, os.path.join(base_dir, "python", "mach"))
sys.path.insert(0, os.path.join(base_dir, "python", "mozboot"))
sys.path.insert(0, os.path.join(base_dir, "python", "mozbuild"))
sys.path.insert(0, os.path.join(base_dir, "testing", "mozbase", "mozfile"))
sys.path.insert(0, os.path.join(base_dir, "third_party", "python", "packaging"))
sys.path.insert(0, os.path.join(base_dir, "third_party", "python", "pyparsing"))
sys.path.insert(0, os.path.join(base_dir, "third_party", "python", "six"))
from mach.site import CommandSiteManager, MachSiteManager, MozSiteMetadata
from mozboot.util import get_state_dir
from mach.site import (
CommandSiteManager,
ExternalPythonSite,
MachSiteManager,
MozSiteMetadata,
SitePackagesSource,
)
from mach.requirements import MachEnvRequirements
from mozbuild.configure import (
ConfigureSandbox,
TRACE,
Expand Down Expand Up @@ -251,13 +256,18 @@ def _activate_build_virtualenv():

topobjdir = os.path.realpath(".")
topsrcdir = os.path.realpath(os.path.dirname(__file__))
state_dir = get_state_dir()

mach_site = MachSiteManager.from_environment(topsrcdir, state_dir)
mach_site = MachSiteManager(
topsrcdir,
None,
MachEnvRequirements(),
ExternalPythonSite(sys.executable),
SitePackagesSource.NONE,
)
mach_site.activate()
build_site = CommandSiteManager.from_environment(
topsrcdir,
state_dir,
None,
"build",
os.path.join(topobjdir, "_virtualenvs"),
)
Expand Down
1 change: 1 addition & 0 deletions moz.configure
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ def bootstrap_path(path, **kwargs):
"Updating" if exists else "Installing",
os.path.join(toolchains_base_dir, path_parts[0]),
)
os.makedirs(toolchains_base_dir, exist_ok=True)
subprocess.run(
[
shell,
Expand Down
4 changes: 2 additions & 2 deletions python/mach/mach/site.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,14 +208,14 @@ def __init__(
self._external_python = external_python
self._site_packages_source = site_packages_source
self._requirements = requirements
self._virtualenv_root = os.path.join(state_dir, "_virtualenvs", "mach")
self._virtualenv_root = _mach_virtualenv_root(state_dir) if state_dir else None
self._metadata = MozSiteMetadata(
sys.hexversion,
"mach",
site_packages_source,
site_packages_source,
external_python,
_mach_virtualenv_root(state_dir),
self._virtualenv_root,
)

@classmethod
Expand Down

0 comments on commit 99bfeba

Please sign in to comment.