forked from mirrors/gecko-dev
Bug 1743592: Don't resolve/create scoped state_dir in CI r=ahal
We only need a workdir-scoped state_dir when an on-disk virtualenv will be created for the Mach site. This change defers the resolution of the state_dir until we know that a VENV will be created. Also modify "telemetry.py" so that it isn't creating a scoped state-dir to compare "sys.executable" against. Differential Revision: https://phabricator.services.mozilla.com/D132706
This commit is contained in:
parent
63bf096aef
commit
0fb9e1cb04
3 changed files with 17 additions and 12 deletions
|
|
@ -166,13 +166,12 @@ install a recent enough Python 3.
|
||||||
""".strip()
|
""".strip()
|
||||||
|
|
||||||
|
|
||||||
def _activate_python_environment(topsrcdir, state_dir):
|
def _activate_python_environment(topsrcdir, get_state_dir):
|
||||||
from mach.site import MachSiteManager
|
from mach.site import MachSiteManager
|
||||||
|
|
||||||
mach_environment = MachSiteManager.from_environment(
|
mach_environment = MachSiteManager.from_environment(
|
||||||
topsrcdir,
|
topsrcdir,
|
||||||
# normpath state_dir to normalize msys-style slashes.
|
get_state_dir,
|
||||||
os.path.normpath(state_dir),
|
|
||||||
)
|
)
|
||||||
mach_environment.activate()
|
mach_environment.activate()
|
||||||
|
|
||||||
|
|
@ -215,7 +214,11 @@ def initialize(topsrcdir):
|
||||||
from mach.util import setenv, get_state_dir
|
from mach.util import setenv, get_state_dir
|
||||||
|
|
||||||
state_dir = _create_state_dir()
|
state_dir = _create_state_dir()
|
||||||
_activate_python_environment(topsrcdir, get_state_dir(True, topsrcdir=topsrcdir))
|
|
||||||
|
# normpath state_dir to normalize msys-style slashes.
|
||||||
|
_activate_python_environment(
|
||||||
|
topsrcdir, lambda: os.path.normpath(get_state_dir(True, topsrcdir=topsrcdir))
|
||||||
|
)
|
||||||
|
|
||||||
import mach.base
|
import mach.base
|
||||||
import mach.main
|
import mach.main
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
import tempfile
|
import tempfile
|
||||||
from contextlib import contextmanager
|
from contextlib import contextmanager
|
||||||
from typing import Optional
|
from typing import Optional, Callable
|
||||||
|
|
||||||
from mach.requirements import (
|
from mach.requirements import (
|
||||||
MachEnvRequirements,
|
MachEnvRequirements,
|
||||||
|
|
@ -219,11 +219,12 @@ class MachSiteManager:
|
||||||
)
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def from_environment(cls, topsrcdir: str, state_dir: str):
|
def from_environment(cls, topsrcdir: str, get_state_dir: Callable[[], str]):
|
||||||
"""
|
"""
|
||||||
Args:
|
Args:
|
||||||
topsrcdir: The path to the Firefox repo
|
topsrcdir: The path to the Firefox repo
|
||||||
state_dir: The path to the state_dir, generally ~/.mozbuild
|
get_state_dir: A function that resolve the path to the workdir-scoped
|
||||||
|
state_dir, generally ~/.mozbuild/srcdirs/<worktree-based-dir>/
|
||||||
"""
|
"""
|
||||||
|
|
||||||
requirements = resolve_requirements(topsrcdir, "mach")
|
requirements = resolve_requirements(topsrcdir, "mach")
|
||||||
|
|
@ -243,14 +244,17 @@ class MachSiteManager:
|
||||||
|
|
||||||
if not _system_python_env_variable_present():
|
if not _system_python_env_variable_present():
|
||||||
source = SitePackagesSource.VENV
|
source = SitePackagesSource.VENV
|
||||||
|
state_dir = get_state_dir()
|
||||||
elif not external_python.has_pip():
|
elif not external_python.has_pip():
|
||||||
source = SitePackagesSource.NONE
|
source = SitePackagesSource.NONE
|
||||||
|
state_dir = None
|
||||||
else:
|
else:
|
||||||
source = (
|
source = (
|
||||||
SitePackagesSource.SYSTEM
|
SitePackagesSource.SYSTEM
|
||||||
if external_python.provides_any_package("mach", requirements)
|
if external_python.provides_any_package("mach", requirements)
|
||||||
else SitePackagesSource.NONE
|
else SitePackagesSource.NONE
|
||||||
)
|
)
|
||||||
|
state_dir = None
|
||||||
|
|
||||||
return cls(
|
return cls(
|
||||||
topsrcdir,
|
topsrcdir,
|
||||||
|
|
|
||||||
|
|
@ -16,13 +16,12 @@ import requests
|
||||||
import six.moves.urllib.parse as urllib_parse
|
import six.moves.urllib.parse as urllib_parse
|
||||||
|
|
||||||
from mach.config import ConfigSettings
|
from mach.config import ConfigSettings
|
||||||
|
from mach.site import MozSiteMetadata
|
||||||
from mach.telemetry_interface import NoopTelemetry, GleanTelemetry
|
from mach.telemetry_interface import NoopTelemetry, GleanTelemetry
|
||||||
from mach.util import get_state_dir
|
from mach.util import get_state_dir
|
||||||
from mozboot.util import get_mach_virtualenv_binary
|
|
||||||
from mozbuild.base import MozbuildObject, BuildEnvironmentNotFoundException
|
from mozbuild.base import MozbuildObject, BuildEnvironmentNotFoundException
|
||||||
from mozbuild.settings import TelemetrySettings
|
from mozbuild.settings import TelemetrySettings
|
||||||
from mozbuild.telemetry import filter_args
|
from mozbuild.telemetry import filter_args
|
||||||
import mozpack.path
|
|
||||||
|
|
||||||
from mozversioncontrol import get_repository_object, InvalidRepoPath
|
from mozversioncontrol import get_repository_object, InvalidRepoPath
|
||||||
|
|
||||||
|
|
@ -39,9 +38,8 @@ def create_telemetry_from_environment(settings):
|
||||||
doesn't support it.
|
doesn't support it.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
is_mach_virtualenv = mozpack.path.normpath(sys.executable) == mozpack.path.normpath(
|
active_metadata = MozSiteMetadata.from_runtime()
|
||||||
get_mach_virtualenv_binary()
|
is_mach_virtualenv = active_metadata and active_metadata.site_name == "mach"
|
||||||
)
|
|
||||||
|
|
||||||
if not (
|
if not (
|
||||||
is_applicable_telemetry_environment()
|
is_applicable_telemetry_environment()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue