Bug 1746325: Defer/avoid creation of scoped state dir for command sites r=ahal

In CI, we sometimes don't have permissions to create a scoped state dir.
Additionally, the current behaviour for resolving the path to a scoped
state dir will also attempt to create it if it doesn't exist.

There's likely a more eloquent solution, but the short-term fix is to
have sites defer the resolution of the state dir until they _know_ they
need it.

Differential Revision: https://phabricator.services.mozilla.com/D134066
This commit is contained in:
Mitchell Hentges 2021-12-20 17:26:17 +00:00
Родитель 2bba81cb45
Коммит 77c1f6c6e9
4 изменённых файлов: 15 добавлений и 7 удалений

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

@ -228,7 +228,7 @@ class MachSiteManager:
"""
Args:
topsrcdir: The path to the Firefox repo
get_state_dir: A function that resolve the path to the checkout-scoped
get_state_dir: A function that resolves the path to the checkout-scoped
state_dir, generally ~/.mozbuild/srcdirs/<checkout-based-dir>/
"""
@ -440,15 +440,15 @@ class CommandSiteManager:
def from_environment(
cls,
topsrcdir: str,
checkout_scoped_state_dir: Optional[str],
get_state_dir: Callable[[], Optional[str]],
site_name: str,
command_virtualenvs_dir: str,
):
"""
Args:
topsrcdir: The path to the Firefox repo
checkout_scoped_state_dir: The path to the checkout-scoped state_dir,
generally ~/.mozbuild/srcdirs/<checkout-based-dir>/
get_state_dir: A function that resolves the path to the checkout-scoped
state_dir, generally ~/.mozbuild/srcdirs/<checkout-based-dir>/
site_name: The name of this site, such as "build"
command_virtualenvs_dir: The location under which this site's virtualenv
should be created
@ -479,6 +479,12 @@ class CommandSiteManager:
else SitePackagesSource.NONE
)
checkout_scoped_state_dir = (
get_state_dir()
if active_metadata.mach_site_packages_source == SitePackagesSource.VENV
else None
)
return cls(
topsrcdir,
checkout_scoped_state_dir,

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

@ -295,7 +295,9 @@ class MozbuildObject(ProcessExecutionMixin):
if self._virtualenv_manager is None:
self._virtualenv_manager = CommandSiteManager.from_environment(
self.topsrcdir,
get_state_dir(specific_to_topsrcdir=True, topsrcdir=self.topsrcdir),
lambda: get_state_dir(
specific_to_topsrcdir=True, topsrcdir=self.topsrcdir
),
self._virtualenv_name,
os.path.join(self.topobjdir, "_virtualenvs"),
)

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

@ -1661,7 +1661,7 @@ class BuildDriver(MozbuildObject):
build_site = CommandSiteManager.from_environment(
self.topsrcdir,
get_state_dir(specific_to_topsrcdir=True, topsrcdir=self.topsrcdir),
lambda: get_state_dir(specific_to_topsrcdir=True, topsrcdir=self.topsrcdir),
"build",
os.path.join(self.topobjdir, "_virtualenvs"),
)

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

@ -217,7 +217,7 @@ def setup(app):
topsrcdir = manager.topsrcdir
site = CommandSiteManager.from_environment(
topsrcdir,
get_state_dir(specific_to_topsrcdir=True, topsrcdir=topsrcdir),
lambda: get_state_dir(specific_to_topsrcdir=True, topsrcdir=topsrcdir),
"common",
os.path.join(app.outdir, "_venv"),
)