Bug 1723237: Move low-hanging fruit commands to centralized Python dep system r=ahal

Creates/updates virtualenvs for some mach commands, replacing
their ad-hoc usage of `install_pip_package()`, `pip install`,
and `sys.path` modifications.

Note: The `docs` virtualenv has `Sphinx==1.1.3` installed, even
though a more modern version of `Sphinx` is used when
`./mach doc` is run. This is ok for now, since `./mach doc` will
just install the newer `Sphinx` over top of the old one. Secondarily,
when we port `./mach doc` to use the centralized system, we'll
be incentivized to make the different `doc` commands use synchonized
versions of the same packages. Success!

Also, note that manual installation of `html5lib` and `requests`
isn't ported to the `wpt` site: this is because they're already
provided by the inherited Mach site.

Differential Revision: https://phabricator.services.mozilla.com/D122902
This commit is contained in:
Mitchell Hentges 2022-03-22 20:49:42 +00:00
parent 6450bc232b
commit 83f95f6c5d
7 changed files with 10 additions and 21 deletions

View File

@ -1 +1,2 @@
pth:tools/lint/eslint
pypi:Sphinx==1.1.3

View File

@ -0,0 +1 @@
pypi:pywatchman==1.4.1

View File

@ -0,0 +1,2 @@
pypi:tox==3.12.1
pypi:ujson==4.0.2

View File

@ -24,6 +24,7 @@ class InvalidPathException(Exception):
"mozbuild-reference",
category="build-dev",
description="View reference documentation on mozbuild files.",
virtualenv_name="docs",
)
@CommandArgument(
"symbol",
@ -39,10 +40,7 @@ class InvalidPathException(Exception):
help="Print symbol names only.",
)
def reference(command_context, symbol, name_only=False):
# mozbuild.sphinx imports some Sphinx modules, so we need to be sure
# the optional Sphinx package is installed.
command_context.activate_virtualenv()
command_context.virtualenv_manager.install_pip_package("Sphinx==1.1.3")
from mozbuild.sphinx import (
format_module,

View File

@ -71,6 +71,7 @@ class StoreDebugParamsAndWarnAction(argparse.Action):
category="post-build",
description="Watch and re-build (parts of) the tree.",
conditions=[conditions.is_firefox],
virtualenv_name="watch",
)
@CommandArgument(
"-v",
@ -93,15 +94,6 @@ def watch(command_context, verbose=False):
return 1
command_context.activate_virtualenv()
try:
command_context.virtualenv_manager.install_pip_package("pywatchman==1.4.1")
except Exception:
print(
"Could not install pywatchman from pip. See "
"https://developer.mozilla.org/docs/Mozilla/Developer_guide/Build_Instructions/Incremental_builds_with_filesystem_watching" # noqa
)
return 1
from mozbuild.faster_daemon import Daemon
daemon = Daemon(command_context.config_environment)

View File

@ -540,12 +540,10 @@ def run_wpt(command_context, **params):
category="testing",
description="Update web-platform-test metadata.",
parser=create_parser_update,
virtualenv_name="wpt",
)
def update_web_platform_tests(command_context, **params):
setup(command_context)
command_context.virtualenv_manager.install_pip_package("html5lib==1.0.1")
command_context.virtualenv_manager.install_pip_package("ujson")
command_context.virtualenv_manager.install_pip_package("requests")
wpt_updater = command_context._spawn(WebPlatformTestsUpdater)
logger = wpt_updater.setup_logging(**params)
@ -623,10 +621,10 @@ def wpt_meta_merge(command_context, **params):
category="testing",
description="Run the wpt tools and wptrunner unit tests",
parser=create_parser_unittest,
virtualenv_name="wpt",
)
def wpt_unittest(command_context, **params):
setup(command_context)
command_context.virtualenv_manager.install_pip_package("tox")
runner = command_context._spawn(WebPlatformTestsUnittestRunner)
return 0 if runner.run(**params) else 1

View File

@ -111,9 +111,8 @@ def build_docs(
linkcheck=None,
verbose=None,
):
command_context.activate_virtualenv()
# TODO: Bug 1704891 - move the ESLint setup tools to a shared place.
sys.path.append(mozpath.join(command_context.topsrcdir, "tools", "lint", "eslint"))
import setup_helper
setup_helper.set_project_root(command_context.topsrcdir)
@ -132,8 +131,6 @@ def build_docs(
+ os.pathsep
+ os.environ["PATH"]
)
command_context.activate_virtualenv()
command_context.virtualenv_manager.install_pip_requirements(
os.path.join(here, "requirements.txt")
)