Bug 985141 - [mozbuild] Remove leading underscore from MozbuildObject._activate_virtualenv, r=firefox-build-system-reviewers,perftest-reviewers,andi,AlexandruIonescu,rstewart

This function is used all across the tree and should be considered a public API.

Differential Revision: https://phabricator.services.mozilla.com/D85045
This commit is contained in:
Andrew Halberstadt 2020-07-28 16:06:10 +00:00
Родитель 1c1c047771
Коммит d0fbcca0b6
19 изменённых файлов: 33 добавлений и 33 удалений

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

@ -155,7 +155,7 @@ def main(argv):
region, bucket = get_s3_region_and_bucket()
config = MozbuildObject.from_environment()
config._activate_virtualenv()
config.activate_virtualenv()
config.virtualenv_manager.install_pip_package('boto3==1.4.4')
with timed() as elapsed:

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

@ -63,7 +63,7 @@ class MachCommands(MachCommandBase):
python_path = sys.executable
append_env['PYTHONPATH'] = os.pathsep.join(sys.path)
else:
self._activate_virtualenv()
self.activate_virtualenv()
python_path = self.virtualenv_manager.python_path
if exec_file:

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

@ -836,7 +836,7 @@ class MozbuildObject(ProcessExecutionMixin):
return cls(self.topsrcdir, self.settings, self.log_manager,
topobjdir=self.topobjdir)
def _activate_virtualenv(self):
def activate_virtualenv(self):
self.virtualenv_manager.ensure()
self.virtualenv_manager.activate()
@ -844,7 +844,7 @@ class MozbuildObject(ProcessExecutionMixin):
self.log_manager.terminal_handler.setLevel(logging.INFO if not verbose else logging.DEBUG)
def ensure_pipenv(self):
self._activate_virtualenv()
self.activate_virtualenv()
pipenv = os.path.join(self.virtualenv_manager.bin_path, 'pipenv')
if not os.path.exists(pipenv):
for package in ['certifi', 'pipenv', 'six', 'virtualenv', 'virtualenv-clone']:
@ -863,7 +863,7 @@ class MozbuildObject(ProcessExecutionMixin):
try:
import zstandard # noqa: F401
except (ImportError, AttributeError):
self._activate_virtualenv()
self.activate_virtualenv()
self.virtualenv_manager.install_pip_package('zstandard>=0.9.0,<=0.13.0')

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

@ -244,7 +244,7 @@ class StaticAnalysis(MachCommandBase):
)
self._set_log_level(verbose)
self._activate_virtualenv()
self.activate_virtualenv()
self.log_manager.enable_unstructured()
rc = self._get_clang_tools(verbose=verbose)
@ -354,7 +354,7 @@ class StaticAnalysis(MachCommandBase):
def check_coverity(self, source=[], output=None, coverity_output_path=None,
outgoing=False, full_build=False, verbose=False):
self._set_log_level(verbose)
self._activate_virtualenv()
self.activate_virtualenv()
self.log_manager.enable_unstructured()
if 'MOZ_AUTOMATION' not in os.environ:
@ -817,7 +817,7 @@ class StaticAnalysis(MachCommandBase):
task='compileWithGeckoBinariesDebugSources',
skip_export=False, outgoing=False, output=None):
self._set_log_level(verbose)
self._activate_virtualenv()
self.activate_virtualenv()
self.log_manager.enable_unstructured()
if self.substs['MOZ_BUILD_APP'] != 'mobile/android':
@ -1082,7 +1082,7 @@ class StaticAnalysis(MachCommandBase):
# checker in particulat and thus 'force_download' becomes 'False' since we want to
# do this on a local trusted clang-tidy package.
self._set_log_level(verbose)
self._activate_virtualenv()
self.activate_virtualenv()
self._dump_results = dump_results
force_download = not self._dump_results

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

@ -37,7 +37,7 @@ class MozbuildFileCommands(MachCommandBase):
def reference(self, symbol, name_only=False):
# mozbuild.sphinx imports some Sphinx modules, so we need to be sure
# the optional Sphinx package is installed.
self._activate_virtualenv()
self.activate_virtualenv()
self.virtualenv_manager.install_pip_package('Sphinx==1.1.3')
from mozbuild.sphinx import (

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

@ -83,7 +83,7 @@ class Watch(MachCommandBase):
'https://developer.mozilla.org/docs/Mozilla/Developer_guide/Build_Instructions/Incremental_builds_with_filesystem_watching') # noqa
return 1
self._activate_virtualenv()
self.activate_virtualenv()
try:
self.virtualenv_manager.install_pip_package('pywatchman==1.4.1')
except Exception:
@ -168,7 +168,7 @@ class Doctor(MachCommandBase):
@CommandArgument('--fix', default=None, action='store_true',
help='Attempt to fix found problems.')
def doctor(self, fix=None):
self._activate_virtualenv()
self.activate_virtualenv()
from mozbuild.doctor import Doctor
doctor = Doctor(self.topsrcdir, self.topobjdir, fix)
return doctor.check_all()

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

@ -28,7 +28,7 @@ class VendorPython(MozbuildObject):
"--with-windows-wheel is only supported for a single package!"
)
self._activate_virtualenv()
self.activate_virtualenv()
pip_compile = os.path.join(self.virtualenv_manager.bin_path, "pip-compile")
if not os.path.exists(pip_compile):
path = os.path.normpath(

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

@ -66,7 +66,7 @@ class Perftest(MachCommandBase):
return
# run locally
MachCommandBase._activate_virtualenv(self)
MachCommandBase.activate_virtualenv(self)
from mozperftest.runner import run_tests
@ -122,7 +122,7 @@ class PerftestTests(MachCommandBase):
"-v", "--verbose", action="store_true", default=False, help="Verbose mode",
)
def run_tests(self, **kwargs):
MachCommandBase._activate_virtualenv(self)
MachCommandBase.activate_virtualenv(self)
from pathlib import Path
from mozperftest.runner import _setup_path

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

@ -26,7 +26,7 @@ class NodeRunner(Layer):
def setup(self):
"""Install the Node.js package.
"""
self.mach_cmd._activate_virtualenv()
self.mach_cmd.activate_virtualenv()
self.verify_node_install()
def node(self, args):

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

@ -53,7 +53,7 @@ class XPCShell(Layer):
self.metrics = []
def setup(self):
self.mach_cmd._activate_virtualenv()
self.mach_cmd.activate_virtualenv()
def run(self, metadata):
tests = self.get_arg("tests", [])

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

@ -15,7 +15,7 @@ requirements = os.path.join(os.path.dirname(__file__), "requirements", "base.txt
@CommandProvider
class CondprofileCommandProvider(MachCommandBase):
def _init(self):
self._activate_virtualenv()
self.activate_virtualenv()
self.virtualenv_manager.install_pip_requirements(
requirements, require_hashes=False
)

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

@ -601,7 +601,7 @@ class JsShellTests(MachCommandBase):
parser=get_jsshell_parser,
description="Run benchmarks in the SpiderMonkey JS shell.")
def run_jsshelltests(self, **kwargs):
self._activate_virtualenv()
self.activate_virtualenv()
from jsshell import benchmark
return benchmark.run(**kwargs)
@ -617,7 +617,7 @@ class CramTest(MachCommandBase):
help="Extra arguments to pass down to the cram binary. See "
"'./mach python -m cram -- -h' for a list of available options.")
def cramtest(self, cram_args=None, test_paths=None, test_objects=None):
self._activate_virtualenv()
self.activate_virtualenv()
import mozinfo
from manifestparser import TestManifest
@ -828,7 +828,7 @@ class TestFluentMigration(MachCommandBase):
def run_migration_tests(self, test_paths=None, **kwargs):
if not test_paths:
test_paths = []
self._activate_virtualenv()
self.activate_virtualenv()
from test_fluent_migrations import fmt
rv = 0
with_context = []

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

@ -290,7 +290,7 @@ class MachCommands(MachCommandBase):
# TODO: This is only strictly necessary while mochitest is using Python
# 2 and can be removed once the command is migrated to Python 3.
self._activate_virtualenv()
self.activate_virtualenv()
buildapp = None
for app in SUPPORTED_APPS:

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

@ -336,7 +336,7 @@ def create_parser_testpaths():
@CommandProvider
class MachCommands(MachCommandBase):
def setup(self):
self._activate_virtualenv()
self.activate_virtualenv()
@Command("web-platform-tests",
category="testing",

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

@ -58,7 +58,7 @@ def get_taskcluster_secret(secret_name):
def main():
config = MozbuildObject.from_environment()
config._activate_virtualenv()
config.activate_virtualenv()
import redo
import requests

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

@ -413,13 +413,13 @@ class MachBrowsertime(MachCommandBase):
site_packages = os.path.abspath(req.satisfied_by.location)
return not site_packages.startswith(venv_site_lib)
def _activate_virtualenv(self, *args, **kwargs):
def activate_virtualenv(self, *args, **kwargs):
r'''Activates virtualenv.
This function will also install Pillow and pyssim if needed.
It will raise an error in case the install failed.
'''
MachCommandBase._activate_virtualenv(self, *args, **kwargs)
MachCommandBase.activate_virtualenv(self, *args, **kwargs)
# installing Python deps on the fly
for dep in ("Pillow==%s" % PILLOW_VERSION, "pyssim==%s" % PYSSIM_VERSION):
@ -428,7 +428,7 @@ class MachBrowsertime(MachCommandBase):
def check(self):
r'''Run `visualmetrics.py --check`.'''
self._activate_virtualenv()
self.activate_virtualenv()
args = ['--check']
status = self.run_process(
@ -576,7 +576,7 @@ class MachBrowsertime(MachCommandBase):
if browsertime_help:
args.append('--help')
self._activate_virtualenv()
self.activate_virtualenv()
default_args = self.extra_default_args(args)
if default_args == 1:
return 1
@ -588,7 +588,7 @@ class MachBrowsertime(MachCommandBase):
@CommandArgument('args', nargs=argparse.REMAINDER)
def visualmetrics(self, video, args):
self._set_log_level(True)
self._activate_virtualenv()
self.activate_virtualenv()
# Turn '/path/to/video/1.mp4' into '/path/to/video' and '1'.
d, base = os.path.split(video)

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

@ -72,7 +72,7 @@ class MachCommands(MachCommandBase):
)
def lint(self, *runargs, **lintargs):
"""Run linters."""
self._activate_virtualenv()
self.activate_virtualenv()
from mozlint import cli, parser
try:

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

@ -345,7 +345,7 @@ def mozregression_create_parser():
# if mozregression is not installed, or not up to date, it will
# first be installed.
cmd = MozbuildObject.from_environment()
cmd._activate_virtualenv()
cmd.activate_virtualenv()
mozregression = mozregression_import()
if not mozregression:
# mozregression is not here at all, install it
@ -383,7 +383,7 @@ class MozregressionCommand(MachCommandBase):
" and inbound builds."),
parser=mozregression_create_parser)
def run(self, **options):
self._activate_virtualenv()
self.activate_virtualenv()
mozregression = mozregression_import()
mozregression.run(options)

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

@ -327,7 +327,7 @@ class TrySelect(MachCommandBase):
has been made, pressing the 'Push' button will automatically push the
selection to try.
"""
self._activate_virtualenv()
self.activate_virtualenv()
path = os.path.join('tools', 'tryselect', 'selectors', 'chooser', 'requirements.txt')
self.virtualenv_manager.install_pip_requirements(path, quiet=True)