From d0fbcca0b615199e8a5fa6a4effe6fa189b686f8 Mon Sep 17 00:00:00 2001 From: Andrew Halberstadt Date: Tue, 28 Jul 2020 16:06:10 +0000 Subject: [PATCH] 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 --- build/upload_generated_sources.py | 2 +- python/mach_commands.py | 2 +- python/mozbuild/mozbuild/base.py | 6 +++--- .../mozbuild/mozbuild/code-analysis/mach_commands.py | 8 ++++---- python/mozbuild/mozbuild/frontend/mach_commands.py | 2 +- python/mozbuild/mozbuild/mach_commands.py | 4 ++-- python/mozbuild/mozbuild/vendor/vendor_python.py | 2 +- python/mozperftest/mozperftest/mach_commands.py | 4 ++-- python/mozperftest/mozperftest/test/noderunner.py | 2 +- python/mozperftest/mozperftest/test/xpcshell.py | 2 +- testing/condprofile/mach_commands.py | 2 +- testing/mach_commands.py | 6 +++--- testing/mochitest/mach_commands.py | 2 +- testing/web-platform/mach_commands.py | 2 +- toolkit/crashreporter/tools/upload_symbols.py | 2 +- tools/browsertime/mach_commands.py | 10 +++++----- tools/lint/mach_commands.py | 2 +- tools/mach_commands.py | 4 ++-- tools/tryselect/mach_commands.py | 2 +- 19 files changed, 33 insertions(+), 33 deletions(-) diff --git a/build/upload_generated_sources.py b/build/upload_generated_sources.py index 1d008e231335..0b5768cdf8d9 100644 --- a/build/upload_generated_sources.py +++ b/build/upload_generated_sources.py @@ -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: diff --git a/python/mach_commands.py b/python/mach_commands.py index 79ecd65666db..f5032d110d50 100644 --- a/python/mach_commands.py +++ b/python/mach_commands.py @@ -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: diff --git a/python/mozbuild/mozbuild/base.py b/python/mozbuild/mozbuild/base.py index 636db40482e1..0aa0408e106d 100644 --- a/python/mozbuild/mozbuild/base.py +++ b/python/mozbuild/mozbuild/base.py @@ -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') diff --git a/python/mozbuild/mozbuild/code-analysis/mach_commands.py b/python/mozbuild/mozbuild/code-analysis/mach_commands.py index 52678ac77285..2852607820e7 100644 --- a/python/mozbuild/mozbuild/code-analysis/mach_commands.py +++ b/python/mozbuild/mozbuild/code-analysis/mach_commands.py @@ -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 diff --git a/python/mozbuild/mozbuild/frontend/mach_commands.py b/python/mozbuild/mozbuild/frontend/mach_commands.py index 66614c0d3047..9d3a21359853 100644 --- a/python/mozbuild/mozbuild/frontend/mach_commands.py +++ b/python/mozbuild/mozbuild/frontend/mach_commands.py @@ -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 ( diff --git a/python/mozbuild/mozbuild/mach_commands.py b/python/mozbuild/mozbuild/mach_commands.py index 026285099345..5f7471236106 100644 --- a/python/mozbuild/mozbuild/mach_commands.py +++ b/python/mozbuild/mozbuild/mach_commands.py @@ -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() diff --git a/python/mozbuild/mozbuild/vendor/vendor_python.py b/python/mozbuild/mozbuild/vendor/vendor_python.py index 14eb1735f1e3..4035038d21a0 100644 --- a/python/mozbuild/mozbuild/vendor/vendor_python.py +++ b/python/mozbuild/mozbuild/vendor/vendor_python.py @@ -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( diff --git a/python/mozperftest/mozperftest/mach_commands.py b/python/mozperftest/mozperftest/mach_commands.py index ca7cec626f75..24097098367c 100644 --- a/python/mozperftest/mozperftest/mach_commands.py +++ b/python/mozperftest/mozperftest/mach_commands.py @@ -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 diff --git a/python/mozperftest/mozperftest/test/noderunner.py b/python/mozperftest/mozperftest/test/noderunner.py index 5fc6a1cd678f..cc6baaacb0d4 100644 --- a/python/mozperftest/mozperftest/test/noderunner.py +++ b/python/mozperftest/mozperftest/test/noderunner.py @@ -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): diff --git a/python/mozperftest/mozperftest/test/xpcshell.py b/python/mozperftest/mozperftest/test/xpcshell.py index d456f07871db..c4450cd6c714 100644 --- a/python/mozperftest/mozperftest/test/xpcshell.py +++ b/python/mozperftest/mozperftest/test/xpcshell.py @@ -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", []) diff --git a/testing/condprofile/mach_commands.py b/testing/condprofile/mach_commands.py index 469211ba17d8..1868f458962e 100644 --- a/testing/condprofile/mach_commands.py +++ b/testing/condprofile/mach_commands.py @@ -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 ) diff --git a/testing/mach_commands.py b/testing/mach_commands.py index b4bdcafa8545..f04dcb1e2a34 100644 --- a/testing/mach_commands.py +++ b/testing/mach_commands.py @@ -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 = [] diff --git a/testing/mochitest/mach_commands.py b/testing/mochitest/mach_commands.py index e9b9f6676b31..ad40b5fa0570 100644 --- a/testing/mochitest/mach_commands.py +++ b/testing/mochitest/mach_commands.py @@ -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: diff --git a/testing/web-platform/mach_commands.py b/testing/web-platform/mach_commands.py index c8ed42be20a1..59abcfed2540 100644 --- a/testing/web-platform/mach_commands.py +++ b/testing/web-platform/mach_commands.py @@ -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", diff --git a/toolkit/crashreporter/tools/upload_symbols.py b/toolkit/crashreporter/tools/upload_symbols.py index 345e8a7240cc..9fdc57cdebb0 100644 --- a/toolkit/crashreporter/tools/upload_symbols.py +++ b/toolkit/crashreporter/tools/upload_symbols.py @@ -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 diff --git a/tools/browsertime/mach_commands.py b/tools/browsertime/mach_commands.py index 10339f1b84c3..8a3c568f60b1 100644 --- a/tools/browsertime/mach_commands.py +++ b/tools/browsertime/mach_commands.py @@ -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) diff --git a/tools/lint/mach_commands.py b/tools/lint/mach_commands.py index b278fa8a6e24..a3dc76f7e573 100644 --- a/tools/lint/mach_commands.py +++ b/tools/lint/mach_commands.py @@ -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: diff --git a/tools/mach_commands.py b/tools/mach_commands.py index c5338c7b7f21..ddba51b7342a 100644 --- a/tools/mach_commands.py +++ b/tools/mach_commands.py @@ -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) diff --git a/tools/tryselect/mach_commands.py b/tools/tryselect/mach_commands.py index d692a6be1cd6..dafed91fa6e2 100644 --- a/tools/tryselect/mach_commands.py +++ b/tools/tryselect/mach_commands.py @@ -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)