Backed out changeset 561899ab9176 (bug 1858065) for breaking local mach browsertime tooling CLOSED TREE

This commit is contained in:
Sandor Molnar 2023-10-16 15:29:57 +03:00
parent 272077c094
commit 4e7d0230df
6 changed files with 23 additions and 27 deletions

View file

@ -5,14 +5,14 @@
import os import os
import platform import platform
import subprocess import subprocess
from distutils.version import StrictVersion
from mozboot.util import get_tools_dir from mozboot.util import get_tools_dir
from mozfile import which from mozfile import which
from packaging.version import Version
from six import PY3 from six import PY3
NODE_MIN_VERSION = Version("12.22.12") NODE_MIN_VERSION = StrictVersion("12.22.12")
NPM_MIN_VERSION = Version("6.14.16") NPM_MIN_VERSION = StrictVersion("6.14.16")
def find_node_paths(): def find_node_paths():
@ -68,7 +68,7 @@ def check_executable_version(exe, wrap_call_with_node=False):
.lstrip("v") .lstrip("v")
.rstrip() .rstrip()
) )
return Version(out) return StrictVersion(out)
def find_node_executable( def find_node_executable(
@ -123,4 +123,4 @@ def find_executable(name, min_version, use_node_for_version_check=False):
if version < min_version: if version < min_version:
return None, None return None, None
return exe, version.release return exe, version.version

View file

@ -3,9 +3,9 @@
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
import re import re
from distutils.version import StrictVersion
from looseversion import LooseVersion from looseversion import LooseVersion
from packaging.version import Version
class MozillaVersionCompareMixin: class MozillaVersionCompareMixin:
@ -17,12 +17,12 @@ class MozillaVersionCompareMixin:
has_esr = set() has_esr = set()
if isinstance(other, LooseModernMozillaVersion) and str(other).endswith("esr"): if isinstance(other, LooseModernMozillaVersion) and str(other).endswith("esr"):
# If other version ends with esr, coerce through MozillaVersion ending up with # If other version ends with esr, coerce through MozillaVersion ending up with
# a Version if possible # a StrictVersion if possible
has_esr.add("other") has_esr.add("other")
other = MozillaVersion(str(other)[:-3]) # strip ESR from end of string other = MozillaVersion(str(other)[:-3]) # strip ESR from end of string
if isinstance(self, LooseModernMozillaVersion) and str(self).endswith("esr"): if isinstance(self, LooseModernMozillaVersion) and str(self).endswith("esr"):
# If our version ends with esr, coerce through MozillaVersion ending up with # If our version ends with esr, coerce through MozillaVersion ending up with
# a Version if possible # a StrictVersion if possible
has_esr.add("self") has_esr.add("self")
self = MozillaVersion(str(self)[:-3]) # strip ESR from end of string self = MozillaVersion(str(self)[:-3]) # strip ESR from end of string
if isinstance(other, LooseModernMozillaVersion) or isinstance( if isinstance(other, LooseModernMozillaVersion) or isinstance(
@ -35,13 +35,8 @@ class MozillaVersionCompareMixin:
LooseModernMozillaVersion(str(other)), LooseModernMozillaVersion(str(other)),
) )
else: else:
# No versions are loose, therefore we can use Version # No versions are loose, therefore we can use StrictVersion
def cmp(a, b): val = StrictVersion._cmp(self, other)
a, b = Version(str(a)), Version(str(b))
return (a > b) - (a < b)
val = cmp(self, other)
if has_esr.isdisjoint(set(["other", "self"])) or has_esr.issuperset( if has_esr.isdisjoint(set(["other", "self"])) or has_esr.issuperset(
set(["other", "self"]) set(["other", "self"])
): ):
@ -56,8 +51,8 @@ class MozillaVersionCompareMixin:
return 1 # non esr is greater than esr return 1 # non esr is greater than esr
class ModernMozillaVersion(MozillaVersionCompareMixin, Version): class ModernMozillaVersion(MozillaVersionCompareMixin, StrictVersion):
"""A version class that is slightly less restrictive than Version. """A version class that is slightly less restrictive than StrictVersion.
Instead of just allowing "a" or "b" as prerelease tags, it allows any Instead of just allowing "a" or "b" as prerelease tags, it allows any
alpha. This allows us to support the once-shipped "3.6.3plugin1" and alpha. This allows us to support the once-shipped "3.6.3plugin1" and
similar versions.""" similar versions."""
@ -69,8 +64,8 @@ class ModernMozillaVersion(MozillaVersionCompareMixin, Version):
) )
class AncientMozillaVersion(MozillaVersionCompareMixin, Version): class AncientMozillaVersion(MozillaVersionCompareMixin, StrictVersion):
"""A version class that is slightly less restrictive than Version. """A version class that is slightly less restrictive than StrictVersion.
Instead of just allowing "a" or "b" as prerelease tags, it allows any Instead of just allowing "a" or "b" as prerelease tags, it allows any
alpha. This allows us to support the once-shipped "3.6.3plugin1" and alpha. This allows us to support the once-shipped "3.6.3plugin1" and
similar versions. similar versions.
@ -87,7 +82,7 @@ class AncientMozillaVersion(MozillaVersionCompareMixin, Version):
class LooseModernMozillaVersion(MozillaVersionCompareMixin, LooseVersion): class LooseModernMozillaVersion(MozillaVersionCompareMixin, LooseVersion):
"""A version class that is more restrictive than LooseVersion. """A version class that is more restrictive than LooseVersion.
This class reduces the valid strings to "esr", "a", "b" and "rc" in order This class reduces the valid strings to "esr", "a", "b" and "rc" in order
to support esr. Version requires a trailing number after all strings.""" to support esr. StrictVersion requires a trailing number after all strings."""
component_re = re.compile(r"(\d+ | a | b | rc | esr | \.)", re.VERBOSE) component_re = re.compile(r"(\d+ | a | b | rc | esr | \.)", re.VERBOSE)

View file

@ -263,10 +263,10 @@ class RaptorRunner(MozbuildObject):
def setup_node(command_context): def setup_node(command_context):
"""Fetch the latest node-16 binary and install it into the .mozbuild directory.""" """Fetch the latest node-16 binary and install it into the .mozbuild directory."""
import platform import platform
from distutils.version import StrictVersion
from mozbuild.artifact_commands import artifact_toolchain from mozbuild.artifact_commands import artifact_toolchain
from mozbuild.nodeutil import find_node_executable from mozbuild.nodeutil import find_node_executable
from packaging.version import Version
print("Setting up node for browsertime...") print("Setting up node for browsertime...")
state_dir = get_state_dir() state_dir = get_state_dir()
@ -274,7 +274,7 @@ def setup_node(command_context):
def __check_for_node(): def __check_for_node():
# Check standard locations first # Check standard locations first
node_exe = find_node_executable(min_version=Version("16.0.0")) node_exe = find_node_executable(min_version=StrictVersion("16.0.0"))
if node_exe and (node_exe[0] is not None): if node_exe and (node_exe[0] is not None):
return node_exe[0] return node_exe[0]
if not os.path.exists(cache_path): if not os.path.exists(cache_path):

View file

@ -81,9 +81,9 @@ def silence():
def node_path(command_context): def node_path(command_context):
import platform import platform
from distutils.version import StrictVersion
from mozbuild.nodeutil import find_node_executable from mozbuild.nodeutil import find_node_executable
from packaging.version import Version
state_dir = command_context._mach_context.state_dir state_dir = command_context._mach_context.state_dir
cache_path = os.path.join(state_dir, "browsertime", "node-16") cache_path = os.path.join(state_dir, "browsertime", "node-16")
@ -97,7 +97,7 @@ def node_path(command_context):
) )
# Check standard locations first # Check standard locations first
node_exe = find_node_executable(min_version=Version(MIN_NODE_VERSION)) node_exe = find_node_executable(min_version=StrictVersion(MIN_NODE_VERSION))
if node_exe and (node_exe[0] is not None): if node_exe and (node_exe[0] is not None):
return os.path.abspath(node_exe[0]) return os.path.abspath(node_exe[0])
if not os.path.exists(cache_path): if not os.path.exists(cache_path):

View file

@ -104,7 +104,7 @@ clippy:
# the version of cargo-clippy is: # the version of cargo-clippy is:
# clippy 0.1.65 (2019147 2022-09-19) # clippy 0.1.65 (2019147 2022-09-19)
# we use the date instead to facilitate the check # we use the date instead to facilitate the check
# replacing - by . because Python packaging.version.Version expects this # replacing - by . because Python StrictVersion expects this
min_clippy_version: 2022.09.19 min_clippy_version: 2022.09.19
type: external type: external
payload: clippy:lint payload: clippy:lint

View file

@ -2,15 +2,16 @@
# License, v. 2.0. If a copy of the MPL was not distributed with this # License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
from distutils.version import StrictVersion
from mach.decorators import Command, CommandArgument from mach.decorators import Command, CommandArgument
from packaging.version import Version
def is_osx_10_10_or_greater(cls): def is_osx_10_10_or_greater(cls):
import platform import platform
release = platform.mac_ver()[0] release = platform.mac_ver()[0]
return release and Version(release) >= Version("10.10") return release and StrictVersion(release) >= StrictVersion("10.10")
# Get system power consumption and related measurements. # Get system power consumption and related measurements.