diff --git a/lib/matplotlib/__init__.py b/lib/matplotlib/__init__.py index 6f146b719751..69cb349325a1 100644 --- a/lib/matplotlib/__init__.py +++ b/lib/matplotlib/__init__.py @@ -278,7 +278,7 @@ def wrapper(**kwargs): return wrapper -_ExecInfo = namedtuple("_ExecInfo", "executable version") +_ExecInfo = namedtuple("_ExecInfo", "executable raw_version version") class ExecutableNotFoundError(FileNotFoundError): @@ -339,12 +339,13 @@ def impl(args, regex, min_ver=None, ignore_exit_code=False): raise ExecutableNotFoundError(str(_ose)) from _ose match = re.search(regex, output) if match: - version = parse_version(match.group(1)) + raw_version = match.group(1) + version = parse_version(raw_version) if min_ver is not None and version < parse_version(min_ver): raise ExecutableNotFoundError( f"You have {args[0]} version {version} but the minimum " f"version supported by Matplotlib is {min_ver}") - return _ExecInfo(args[0], version) + return _ExecInfo(args[0], raw_version, version) else: raise ExecutableNotFoundError( f"Failed to determine the version of {args[0]} from " @@ -401,7 +402,7 @@ def impl(args, regex, min_ver=None, ignore_exit_code=False): else: path = "convert" info = impl([path, "--version"], r"^Version: ImageMagick (\S*)") - if info.version == parse_version("7.0.10-34"): + if info.raw_version == "7.0.10-34": # https://github.com/ImageMagick/ImageMagick/issues/2720 raise ExecutableNotFoundError( f"You have ImageMagick {info.version}, which is unsupported") diff --git a/lib/matplotlib/backends/qt_compat.py b/lib/matplotlib/backends/qt_compat.py index 9e320e341c4c..a8861f3db5f8 100644 --- a/lib/matplotlib/backends/qt_compat.py +++ b/lib/matplotlib/backends/qt_compat.py @@ -134,9 +134,8 @@ def _isdeleted(obj): # https://bugreports.qt.io/browse/QTBUG-87014, fixed in qt 5.15.2 if (sys.platform == 'darwin' and parse_version(platform.mac_ver()[0]) >= parse_version("10.16") and - parse_version(QtCore.qVersion()) < parse_version("5.15.2") and - "QT_MAC_WANTS_LAYER" not in os.environ): - os.environ["QT_MAC_WANTS_LAYER"] = "1" + QtCore.QLibraryInfo.version().segments() <= [5, 15, 2]): + os.environ.setdefault("QT_MAC_WANTS_LAYER", "1") # PyQt6 enum compat helpers. diff --git a/lib/matplotlib/texmanager.py b/lib/matplotlib/texmanager.py index 62aca98a32b6..c9960c8c14cd 100644 --- a/lib/matplotlib/texmanager.py +++ b/lib/matplotlib/texmanager.py @@ -29,7 +29,6 @@ from tempfile import TemporaryDirectory import numpy as np -from packaging.version import parse as parse_version import matplotlib as mpl from matplotlib import _api, cbook, dviread, rcParams @@ -291,9 +290,8 @@ def make_png(self, tex, fontsize, dpi): # dvipng 1.16 has a bug (fixed in f3ff241) that breaks --freetype0 # mode, so for it we keep FreeType enabled; the image will be # slightly off. - bad_ver = parse_version("1.16") - if (getattr(mpl, "_called_from_pytest", False) - and mpl._get_executable_info("dvipng").version != bad_ver): + if (getattr(mpl, "_called_from_pytest", False) and + mpl._get_executable_info("dvipng").raw_version != "1.16"): cmd.insert(1, "--freetype0") self._run_checked_subprocess(cmd, tex) return pngfile