Skip to content

Commit

Permalink
Bug 985141 - [mozbuild] Remove leading underscore from MozbuildObject…
Browse files Browse the repository at this point in the history
…._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
  • Loading branch information
ahal committed Jul 28, 2020
1 parent 1c1c047 commit d0fbcca
Show file tree
Hide file tree
Showing 19 changed files with 33 additions and 33 deletions.
2 changes: 1 addition & 1 deletion build/upload_generated_sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion python/mach_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def python(self, no_virtualenv, exec_file, ipython, args):
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:
Expand Down
6 changes: 3 additions & 3 deletions python/mozbuild/mozbuild/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -836,15 +836,15 @@ def _spawn(self, cls):
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()

def _set_log_level(self, verbose):
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']:
Expand All @@ -863,7 +863,7 @@ def _ensure_zstd(self):
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')


Expand Down
8 changes: 4 additions & 4 deletions python/mozbuild/mozbuild/code-analysis/mach_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ def check(self, source=None, jobs=2, strip=1, verbose=False, checks='-*',
)

self._set_log_level(verbose)
self._activate_virtualenv()
self.activate_virtualenv()
self.log_manager.enable_unstructured()

rc = self._get_clang_tools(verbose=verbose)
Expand Down Expand Up @@ -354,7 +354,7 @@ def check(self, source=None, jobs=2, strip=1, verbose=False, checks='-*',
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:
Expand Down Expand Up @@ -817,7 +817,7 @@ def check_java(self, source=['mobile'], jobs=2, strip=1, verbose=False, checks=[
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':
Expand Down Expand Up @@ -1082,7 +1082,7 @@ def autotest(self, verbose=False, dump_results=False, intree_tool=False, checker
# 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
Expand Down
2 changes: 1 addition & 1 deletion python/mozbuild/mozbuild/frontend/mach_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
4 changes: 2 additions & 2 deletions python/mozbuild/mozbuild/mach_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def watch(self, verbose=False):
'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:
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion python/mozbuild/mozbuild/vendor/vendor_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def vendor(self, packages=None, with_windows_wheel=False, keep_extra_files=False
"--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(
Expand Down
4 changes: 2 additions & 2 deletions python/mozperftest/mozperftest/mach_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def run_perftest(self, **kwargs):
return

# run locally
MachCommandBase._activate_virtualenv(self)
MachCommandBase.activate_virtualenv(self)

from mozperftest.runner import run_tests

Expand Down Expand Up @@ -122,7 +122,7 @@ def _run_python_script(self, module, *args, **kw):
"-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
Expand Down
2 changes: 1 addition & 1 deletion python/mozperftest/mozperftest/test/noderunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def __init__(self, env, mach_cmd):
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):
Expand Down
2 changes: 1 addition & 1 deletion python/mozperftest/mozperftest/test/xpcshell.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def __init__(self, env, mach_cmd):
self.metrics = []

def setup(self):
self.mach_cmd._activate_virtualenv()
self.mach_cmd.activate_virtualenv()

def run(self, metadata):
tests = self.get_arg("tests", [])
Expand Down
2 changes: 1 addition & 1 deletion testing/condprofile/mach_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
@CommandProvider
class CondprofileCommandProvider(MachCommandBase):
def _init(self):
self._activate_virtualenv()
self.activate_virtualenv()
self.virtualenv_manager.install_pip_requirements(
requirements, require_hashes=False
)
Expand Down
6 changes: 3 additions & 3 deletions testing/mach_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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

Expand Down Expand Up @@ -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 = []
Expand Down
2 changes: 1 addition & 1 deletion testing/mochitest/mach_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ def run_mochitest_general(self, flavor=None, test_objects=None, resolve_tests=Tr

# 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:
Expand Down
2 changes: 1 addition & 1 deletion testing/web-platform/mach_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion toolkit/crashreporter/tools/upload_symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 5 additions & 5 deletions tools/browsertime/mach_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -413,13 +413,13 @@ def _need_install(self, package):
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):
Expand All @@ -428,7 +428,7 @@ def _activate_virtualenv(self, *args, **kwargs):

def check(self):
r'''Run `visualmetrics.py --check`.'''
self._activate_virtualenv()
self.activate_virtualenv()

args = ['--check']
status = self.run_process(
Expand Down Expand Up @@ -576,7 +576,7 @@ def browsertime(self, args, verbose=False,
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
Expand All @@ -588,7 +588,7 @@ def browsertime(self, args, verbose=False,
@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)
Expand Down
2 changes: 1 addition & 1 deletion tools/lint/mach_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions tools/mach_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)

Expand Down
2 changes: 1 addition & 1 deletion tools/tryselect/mach_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def try_chooser(self, **kwargs):
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)

Expand Down

0 comments on commit d0fbcca

Please sign in to comment.