Commit 2a66b39b authored by Mitchell Hentges's avatar Mitchell Hentges
Browse files

Bug 1641962: Defer imports of distutils.util to ensure bootstrap can run...

Bug 1641962: Defer imports of distutils.util to ensure bootstrap can run r=rstewart,perftest-reviewers,sparky

Differential Revision: https://phabricator.services.mozilla.com/D77516
parent 1b525e3c
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -15,7 +15,6 @@ from six import text_type
import sys
import traceback
import re
from distutils.util import strtobool

from mach.decorators import (
    CommandArgument,
@@ -27,6 +26,18 @@ from mach.decorators import (
from mozbuild.base import MachCommandBase


def strtobool(value):
    """Convert string to boolean.

    Wraps "distutils.util.strtobool", deferring the import of the package
    in case it's not installed. Otherwise, we have a "chicken and egg problem" where
    |mach bootstrap| would install the required package to enable "distutils.util", but
    it can't because mach fails to interpret this file.
    """
    from distutils.util import strtobool
    return bool(strtobool(value))


class ShowTaskGraphSubCommand(SubCommand):
    """A SubCommand with TaskGraph-specific arguments"""

@@ -162,7 +173,7 @@ class MachCommands(MachCommandBase):
    @CommandArgument('--target-tasks-method', type=text_type,
                     help='method for selecting the target tasks to generate')
    @CommandArgument('--optimize-target-tasks',
                     type=lambda flag: bool(strtobool(flag)),
                     type=lambda flag: strtobool(flag),
                     nargs='?', const='true',
                     help='If specified, this indicates whether the target '
                          'tasks are eligible for optimization. Otherwise, '
+4 −1
Original line number Diff line number Diff line
@@ -25,7 +25,6 @@ from mozbuild.base import (
    BinaryNotFoundException,
)
from mozbuild.base import MachCommandConditions as Conditions
from raptor.power import enable_charging, disable_charging

HERE = os.path.dirname(os.path.realpath(__file__))

@@ -222,6 +221,10 @@ class MachRaptor(MachCommandBase):
             description='Run Raptor performance tests.',
             parser=create_parser)
    def run_raptor(self, **kwargs):
        # Defers this import so that a transitive dependency doesn't
        # stop |mach bootstrap| from running
        from raptor.power import enable_charging, disable_charging

        build_obj = self

        is_android = Conditions.is_android(build_obj) or \