diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-08 15:11:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-08 15:11:27 +0000 |
commit | f3bcaf9f88aad2c423ebcd61121562f9834187d4 (patch) | |
tree | f22238c29b57707b645a350940e3e9bdf3ce1f5d /python | |
parent | Adding debian version 115.7.0esr-1~deb12u1. (diff) | |
download | firefox-esr-f3bcaf9f88aad2c423ebcd61121562f9834187d4.tar.xz firefox-esr-f3bcaf9f88aad2c423ebcd61121562f9834187d4.zip |
Merging upstream version 115.8.0esr.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'python')
-rw-r--r-- | python/mach/mach/main.py | 8 | ||||
-rw-r--r-- | python/mach/mach/test/test_entry_point.py | 4 | ||||
-rw-r--r-- | python/mozboot/mozboot/base.py | 7 | ||||
-rw-r--r-- | python/mozboot/mozboot/bootstrap.py | 16 | ||||
-rw-r--r-- | python/mozboot/mozboot/debian.py | 7 | ||||
-rw-r--r-- | python/mozboot/setup.py | 5 | ||||
-rw-r--r-- | python/mozbuild/mozbuild/mach_commands.py | 6 | ||||
-rw-r--r-- | python/mozbuild/mozbuild/nodeutil.py | 12 | ||||
-rw-r--r-- | python/mozrelease/mozrelease/versions.py | 56 | ||||
-rw-r--r-- | python/mozrelease/test/test_versions.py | 21 | ||||
-rw-r--r-- | python/sites/mach.txt | 2 |
11 files changed, 94 insertions, 50 deletions
diff --git a/python/mach/mach/main.py b/python/mach/mach/main.py index 9ab880341d..6c32ce2058 100644 --- a/python/mach/mach/main.py +++ b/python/mach/mach/main.py @@ -8,16 +8,18 @@ import argparse import codecs import errno -import imp import logging import os import sys import traceback +import types import uuid from collections.abc import Iterable from pathlib import Path from typing import Dict, List, Union +from mozfile import load_source + from .base import ( CommandContext, FailedCommandError, @@ -267,13 +269,13 @@ To see more help for a specific command, run: # Ensure parent module is present otherwise we'll (likely) get # an error due to unknown parent. if "mach.commands" not in sys.modules: - mod = imp.new_module("mach.commands") + mod = types.ModuleType("mach.commands") sys.modules["mach.commands"] = mod module_name = f"mach.commands.{uuid.uuid4().hex}" try: - imp.load_source(module_name, str(path)) + load_source(module_name, str(path)) except IOError as e: if e.errno != errno.ENOENT: raise diff --git a/python/mach/mach/test/test_entry_point.py b/python/mach/mach/test/test_entry_point.py index 1129eba476..11aa083cda 100644 --- a/python/mach/mach/test/test_entry_point.py +++ b/python/mach/mach/test/test_entry_point.py @@ -1,8 +1,8 @@ # This Source Code Form is subject to the terms of the Mozilla Public # 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/. -import imp import sys +import types from pathlib import Path from unittest.mock import patch @@ -38,7 +38,7 @@ class TestEntryPoints(TestBase): # Ensure parent module is present otherwise we'll (likely) get # an error due to unknown parent. if "mach.commands" not in sys.modules: - mod = imp.new_module("mach.commands") + mod = types.ModuleType("mach.commands") sys.modules["mach.commands"] = mod mock.return_value = [Entry([self.provider_dir])] diff --git a/python/mozboot/mozboot/base.py b/python/mozboot/mozboot/base.py index c32946c4eb..9f4a81ca01 100644 --- a/python/mozboot/mozboot/base.py +++ b/python/mozboot/mozboot/base.py @@ -170,13 +170,6 @@ class BaseBootstrapper(object): to the user, if necessary. """ - def suggest_install_distutils(self): - """Called if distutils.{sysconfig,spawn} can't be imported.""" - print( - "Does your distro require installing another package for distutils?", - file=sys.stderr, - ) - def suggest_install_pip3(self): """Called if pip3 can't be found.""" print( diff --git a/python/mozboot/mozboot/bootstrap.py b/python/mozboot/mozboot/bootstrap.py index e57f496f29..c2b7480b8e 100644 --- a/python/mozboot/mozboot/bootstrap.py +++ b/python/mozboot/mozboot/bootstrap.py @@ -491,22 +491,6 @@ class Bootstrapper(object): def _validate_python_environment(self, topsrcdir): valid = True - try: - # distutils is singled out here because some distros (namely Ubuntu) - # include it in a separate package outside of the main Python - # installation. - import distutils.spawn - import distutils.sysconfig - - assert distutils.sysconfig is not None and distutils.spawn is not None - except ImportError as e: - print("ERROR: Could not import package %s" % e.name, file=sys.stderr) - self.instance.suggest_install_distutils() - valid = False - except AssertionError: - print("ERROR: distutils is not behaving as expected.", file=sys.stderr) - self.instance.suggest_install_distutils() - valid = False pip3 = to_optional_path(which("pip3")) if not pip3: print("ERROR: Could not find pip3.", file=sys.stderr) diff --git a/python/mozboot/mozboot/debian.py b/python/mozboot/mozboot/debian.py index 34e328586e..63b47a2f03 100644 --- a/python/mozboot/mozboot/debian.py +++ b/python/mozboot/mozboot/debian.py @@ -17,13 +17,6 @@ class DebianBootstrapper(LinuxBootstrapper, BaseBootstrapper): self.dist_id = dist_id self.codename = codename - def suggest_install_distutils(self): - print( - "HINT: Try installing distutils with " - "`apt-get install python3-distutils`.", - file=sys.stderr, - ) - def suggest_install_pip3(self): print( "HINT: Try installing pip3 with `apt-get install python3-pip`.", diff --git a/python/mozboot/setup.py b/python/mozboot/setup.py index 234650dc8a..7b12c1c0c5 100644 --- a/python/mozboot/setup.py +++ b/python/mozboot/setup.py @@ -2,7 +2,10 @@ # 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/. -from distutils.core import setup +try: + from setuptools import setup +except ImportError: + from distutils.core import setup VERSION = "0.1" diff --git a/python/mozbuild/mozbuild/mach_commands.py b/python/mozbuild/mozbuild/mach_commands.py index 2297d586b8..c00afd1c01 100644 --- a/python/mozbuild/mozbuild/mach_commands.py +++ b/python/mozbuild/mozbuild/mach_commands.py @@ -29,6 +29,7 @@ from mach.decorators import ( SettingsProvider, SubCommand, ) +from mozfile import load_source from voluptuous import All, Boolean, Required, Schema import mozbuild.settings # noqa need @SettingsProvider hook to execute @@ -1099,11 +1100,10 @@ def android_gtest( # run gtest via remotegtests.py exit_code = 0 - import imp path = os.path.join("testing", "gtest", "remotegtests.py") - with open(path, "r") as fh: - imp.load_module("remotegtests", fh, path, (".py", "r", imp.PY_SOURCE)) + load_source("remotegtests", path) + import remotegtests tester = remotegtests.RemoteGTests() diff --git a/python/mozbuild/mozbuild/nodeutil.py b/python/mozbuild/mozbuild/nodeutil.py index 8ec724ab89..42f2627cd9 100644 --- a/python/mozbuild/mozbuild/nodeutil.py +++ b/python/mozbuild/mozbuild/nodeutil.py @@ -5,14 +5,14 @@ import os import platform import subprocess -from distutils.version import StrictVersion from mozboot.util import get_tools_dir from mozfile import which +from packaging.version import Version from six import PY3 -NODE_MIN_VERSION = StrictVersion("12.22.12") -NPM_MIN_VERSION = StrictVersion("6.14.16") +NODE_MIN_VERSION = Version("12.22.12") +NPM_MIN_VERSION = Version("6.14.16") def find_node_paths(): @@ -68,7 +68,7 @@ def check_executable_version(exe, wrap_call_with_node=False): .lstrip("v") .rstrip() ) - return StrictVersion(out) + return Version(out) def find_node_executable( @@ -87,7 +87,7 @@ def find_node_executable( return None, None if version >= min_version: - return nodejs_exe, version.version + return nodejs_exe, version.release return None, None @@ -123,4 +123,4 @@ def find_executable(name, min_version, use_node_for_version_check=False): if version < min_version: return None, None - return exe, version.version + return exe, version.release diff --git a/python/mozrelease/mozrelease/versions.py b/python/mozrelease/mozrelease/versions.py index e3e47d4e4a..348b77bd75 100644 --- a/python/mozrelease/mozrelease/versions.py +++ b/python/mozrelease/mozrelease/versions.py @@ -3,9 +3,59 @@ # file, You can obtain one at http://mozilla.org/MPL/2.0/. import re -from distutils.version import StrictVersion from looseversion import LooseVersion +from packaging.version import InvalidVersion + + +class StrictVersion: + def __init__(self, vstring): + self.parse(vstring) + + def __repr__(self): + return "%s ('%s')" % (self.__class__.__name__, str(self)) + + def __eq__(self, other): + return self._cmp(other) == 0 + + def __lt__(self, other): + return self._cmp(other) < 0 + + def parse(self, vstring): + match = self.version_re.match(vstring) + if not match: + raise InvalidVersion("invalid version number '%s'" % vstring) + + major, minor, patch, pre, pre_num = match.group(1, 2, 4, 5, 6) + self.version = int(major), int(minor), int(patch or 0) + self.pre = (pre[0], int(pre_num)) if pre else () + + def __str__(self): + return ".".join(map(str, self.version)) + ( + "".join(map(str, self.pre)) if self.pre else "" + ) + + def _cmp(self, other): + if isinstance(other, str): + other = StrictVersion(other) + elif not isinstance(other, StrictVersion): + raise NotImplementedError + + if self.version < other.version: + return -1 + elif self.version == other.version: + if self.pre == other.pre: + return 0 + elif not self.pre: + return 1 + elif not other.pre: + return -1 + elif self.pre < other.pre: + return -1 + else: + return 1 + else: + return 1 class MozillaVersionCompareMixin: @@ -93,12 +143,12 @@ class LooseModernMozillaVersion(MozillaVersionCompareMixin, LooseVersion): def MozillaVersion(version): try: return ModernMozillaVersion(version) - except ValueError: + except InvalidVersion: pass try: if version.count(".") == 3: return AncientMozillaVersion(version) - except ValueError: + except InvalidVersion: pass try: return LooseModernMozillaVersion(version) diff --git a/python/mozrelease/test/test_versions.py b/python/mozrelease/test/test_versions.py index f3bca91f1f..eaf7d653db 100644 --- a/python/mozrelease/test/test_versions.py +++ b/python/mozrelease/test/test_versions.py @@ -1,7 +1,11 @@ import mozunit import pytest -from mozrelease.versions import MozillaVersion +from mozrelease.versions import ( + AncientMozillaVersion, + ModernMozillaVersion, + MozillaVersion, +) ALL_VERSIONS = [ # Keep this sorted "3.0", @@ -91,6 +95,21 @@ def test_versions_compare_greater(comparable_versions): assert MozillaVersion(larger_version) > MozillaVersion(smaller_version) +def test_ModernMozillaVersion(): + """Test properties specific to ModernMozillaVersion""" + assert isinstance(MozillaVersion("1.2.4"), ModernMozillaVersion) + assert isinstance(MozillaVersion("1.2.4rc3"), ModernMozillaVersion) + assert MozillaVersion("1.2rc3") == MozillaVersion("1.2.0rc3") + + +def test_AncientMozillaVersion(): + """Test properties specific to AncientMozillaVersion""" + assert isinstance(MozillaVersion("1.2.0.4"), AncientMozillaVersion) + assert isinstance(MozillaVersion("1.2.0.4pre1"), AncientMozillaVersion) + assert MozillaVersion("1.2pre1") == MozillaVersion("1.2.0pre1") + assert MozillaVersion("1.2.0.4pre1") == MozillaVersion("1.2.4pre1") + + @pytest.mark.parametrize("version", ALL_VERSIONS) def test_versions_compare_equal(version): """Test that versions properly compare as equal through multiple passes.""" diff --git a/python/sites/mach.txt b/python/sites/mach.txt index 55cc6fb2ed..a597630083 100644 --- a/python/sites/mach.txt +++ b/python/sites/mach.txt @@ -106,7 +106,7 @@ vendored:third_party/python/pylru vendored:third_party/python/pyparsing vendored:third_party/python/pyrsistent vendored:third_party/python/python-hglib -vendored:third_party/python/PyYAML/lib3/ +vendored:third_party/python/PyYAML/lib vendored:third_party/python/redo vendored:third_party/python/requests vendored:third_party/python/requests_unixsocket |