Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 87b9118

Browse filesBrowse files
authored
Merge pull request #20437 from QuLogic/packaging
2 parents b71ee62 + 7d77bb9 commit 87b9118
Copy full SHA for 87b9118

File tree

Expand file treeCollapse file tree

11 files changed

+39
-30
lines changed
Filter options
Expand file treeCollapse file tree

11 files changed

+39
-30
lines changed

‎.github/workflows/tests.yml

Copy file name to clipboardExpand all lines: .github/workflows/tests.yml
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,8 @@ jobs:
145145
146146
# Install dependencies from PyPI.
147147
python -m pip install --upgrade $PRE \
148-
cycler kiwisolver numpy pillow pyparsing python-dateutil setuptools-scm \
148+
cycler kiwisolver numpy packaging pillow pyparsing python-dateutil \
149+
setuptools-scm \
149150
-r requirements/testing/all.txt \
150151
${{ matrix.extra-requirements }}
151152

‎examples/units/basic_units.py

Copy file name to clipboardExpand all lines: examples/units/basic_units.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
66
"""
77

8-
from distutils.version import LooseVersion
98
import math
109

1110
import numpy as np
11+
from packaging.version import parse as parse_version
1212

1313
import matplotlib.units as units
1414
import matplotlib.ticker as ticker
@@ -155,7 +155,7 @@ def __str__(self):
155155
def __len__(self):
156156
return len(self.value)
157157

158-
if LooseVersion(np.__version__) >= '1.20':
158+
if parse_version(np.__version__) >= parse_version('1.20'):
159159
def __getitem__(self, key):
160160
return TaggedValue(self.value[key], self.unit)
161161

‎lib/matplotlib/__init__.py

Copy file name to clipboardExpand all lines: lib/matplotlib/__init__.py
+12-12Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@
8585
from collections import namedtuple
8686
from collections.abc import MutableMapping
8787
import contextlib
88-
from distutils.version import LooseVersion
8988
import functools
9089
import importlib
9190
import inspect
@@ -103,6 +102,7 @@
103102
import warnings
104103

105104
import numpy
105+
from packaging.version import parse as parse_version
106106

107107
# cbook must import matplotlib only within function
108108
# definitions, so it is safe to import from it here.
@@ -165,9 +165,9 @@ def _check_versions():
165165
("pyparsing", "2.2.1"),
166166
]:
167167
module = importlib.import_module(modname)
168-
if LooseVersion(module.__version__) < minver:
169-
raise ImportError("Matplotlib requires {}>={}; you have {}"
170-
.format(modname, minver, module.__version__))
168+
if parse_version(module.__version__) < parse_version(minver):
169+
raise ImportError(f"Matplotlib requires {modname}>={minver}; "
170+
f"you have {module.__version__}")
171171

172172

173173
_check_versions()
@@ -274,8 +274,7 @@ def _get_executable_info(name):
274274
-------
275275
tuple
276276
A namedtuple with fields ``executable`` (`str`) and ``version``
277-
(`distutils.version.LooseVersion`, or ``None`` if the version cannot be
278-
determined).
277+
(`packaging.Version`, or ``None`` if the version cannot be determined).
279278
280279
Raises
281280
------
@@ -305,8 +304,8 @@ def impl(args, regex, min_ver=None, ignore_exit_code=False):
305304
raise ExecutableNotFoundError(str(_ose)) from _ose
306305
match = re.search(regex, output)
307306
if match:
308-
version = LooseVersion(match.group(1))
309-
if min_ver is not None and version < min_ver:
307+
version = parse_version(match.group(1))
308+
if min_ver is not None and version < parse_version(min_ver):
310309
raise ExecutableNotFoundError(
311310
f"You have {args[0]} version {version} but the minimum "
312311
f"version supported by Matplotlib is {min_ver}")
@@ -367,17 +366,18 @@ def impl(args, regex, min_ver=None, ignore_exit_code=False):
367366
else:
368367
path = "convert"
369368
info = impl([path, "--version"], r"^Version: ImageMagick (\S*)")
370-
if info.version == "7.0.10-34":
369+
if info.version == parse_version("7.0.10-34"):
371370
# https://github.com/ImageMagick/ImageMagick/issues/2720
372371
raise ExecutableNotFoundError(
373372
f"You have ImageMagick {info.version}, which is unsupported")
374373
return info
375374
elif name == "pdftops":
376375
info = impl(["pdftops", "-v"], "^pdftops version (.*)",
377376
ignore_exit_code=True)
378-
if info and not ("3.0" <= info.version
379-
# poppler version numbers.
380-
or "0.9" <= info.version <= "1.0"):
377+
if info and not (
378+
3 <= info.version.major or
379+
# poppler version numbers.
380+
parse_version("0.9") <= info.version < parse_version("1.0")):
381381
raise ExecutableNotFoundError(
382382
f"You have pdftops version {info.version} but the minimum "
383383
f"version supported by Matplotlib is 3.0")

‎lib/matplotlib/backends/qt_compat.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/qt_compat.py
+4-3Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
- otherwise, use whatever the rcParams indicate.
1212
"""
1313

14-
from distutils.version import LooseVersion
1514
import os
1615
import platform
1716
import sys
1817

18+
from packaging.version import parse as parse_version
19+
1920
import matplotlib as mpl
2021

2122

@@ -102,8 +103,8 @@ def _isdeleted(obj): return not shiboken2.isValid(obj)
102103
# Fixes issues with Big Sur
103104
# https://bugreports.qt.io/browse/QTBUG-87014, fixed in qt 5.15.2
104105
if (sys.platform == 'darwin' and
105-
LooseVersion(platform.mac_ver()[0]) >= LooseVersion("10.16") and
106-
LooseVersion(QtCore.qVersion()) < LooseVersion("5.15.2") and
106+
parse_version(platform.mac_ver()[0]) >= parse_version("10.16") and
107+
parse_version(QtCore.qVersion()) < parse_version("5.15.2") and
107108
"QT_MAC_WANTS_LAYER" not in os.environ):
108109
os.environ["QT_MAC_WANTS_LAYER"] = "1"
109110

‎lib/matplotlib/testing/compare.py

Copy file name to clipboardExpand all lines: lib/matplotlib/testing/compare.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def encode_and_escape(name):
167167

168168
class _SVGConverter(_Converter):
169169
def __call__(self, orig, dest):
170-
old_inkscape = mpl._get_executable_info("inkscape").version < "1"
170+
old_inkscape = mpl._get_executable_info("inkscape").version.major < 1
171171
terminator = b"\n>" if old_inkscape else b"> "
172172
if not hasattr(self, "_tmpdir"):
173173
self._tmpdir = TemporaryDirectory()

‎lib/matplotlib/testing/decorators.py

Copy file name to clipboardExpand all lines: lib/matplotlib/testing/decorators.py
+8-7Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import contextlib
2-
from distutils.version import StrictVersion
32
import functools
43
import inspect
54
import os
@@ -10,6 +9,8 @@
109
import unittest
1110
import warnings
1211

12+
from packaging.version import parse as parse_version
13+
1314
import matplotlib.style
1415
import matplotlib.units
1516
import matplotlib.testing
@@ -92,20 +93,20 @@ def check_freetype_version(ver):
9293

9394
if isinstance(ver, str):
9495
ver = (ver, ver)
95-
ver = [StrictVersion(x) for x in ver]
96-
found = StrictVersion(ft2font.__freetype_version__)
96+
ver = [parse_version(x) for x in ver]
97+
found = parse_version(ft2font.__freetype_version__)
9798

9899
return ver[0] <= found <= ver[1]
99100

100101

101102
def _checked_on_freetype_version(required_freetype_version):
102103
import pytest
103-
reason = ("Mismatched version of freetype. "
104-
"Test requires '%s', you have '%s'" %
105-
(required_freetype_version, ft2font.__freetype_version__))
106104
return pytest.mark.xfail(
107105
not check_freetype_version(required_freetype_version),
108-
reason=reason, raises=ImageComparisonFailure, strict=False)
106+
reason=f"Mismatched version of freetype. "
107+
f"Test requires '{required_freetype_version}', "
108+
f"you have '{ft2font.__freetype_version__}'",
109+
raises=ImageComparisonFailure, strict=False)
109110

110111

111112
def remove_ticks_and_titles(figure):

‎lib/matplotlib/tests/test_backend_pgf.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_backend_pgf.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import shutil
55

66
import numpy as np
7+
from packaging.version import parse as parse_version
78
import pytest
89

910
import matplotlib as mpl
@@ -88,7 +89,8 @@ def test_xelatex():
8889

8990

9091
try:
91-
_old_gs_version = mpl._get_executable_info('gs').version < '9.50'
92+
_old_gs_version = \
93+
mpl._get_executable_info('gs').version < parse_version('9.50')
9294
except mpl.ExecutableNotFoundError:
9395
_old_gs_version = True
9496

‎lib/matplotlib/tests/tinypages/conf.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/tinypages/conf.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import sphinx
2-
from distutils.version import LooseVersion
2+
from packaging.version import parse as parse_version
33

44
# -- General configuration ------------------------------------------------
55

@@ -16,7 +16,7 @@
1616

1717
# -- Options for HTML output ----------------------------------------------
1818

19-
if LooseVersion(sphinx.__version__) >= LooseVersion('1.3'):
19+
if parse_version(sphinx.__version__) >= parse_version('1.3'):
2020
html_theme = 'classic'
2121
else:
2222
html_theme = 'default'

‎lib/matplotlib/texmanager.py

Copy file name to clipboardExpand all lines: lib/matplotlib/texmanager.py
+3-1Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from tempfile import TemporaryDirectory
3030

3131
import numpy as np
32+
from packaging.version import parse as parse_version
3233

3334
import matplotlib as mpl
3435
from matplotlib import _api, cbook, dviread, rcParams
@@ -270,8 +271,9 @@ def make_png(self, tex, fontsize, dpi):
270271
# dvipng 1.16 has a bug (fixed in f3ff241) that breaks --freetype0
271272
# mode, so for it we keep FreeType enabled; the image will be
272273
# slightly off.
274+
bad_ver = parse_version("1.16")
273275
if (getattr(mpl, "_called_from_pytest", False)
274-
and mpl._get_executable_info("dvipng").version != "1.16"):
276+
and mpl._get_executable_info("dvipng").version != bad_ver):
275277
cmd.insert(1, "--freetype0")
276278
self._run_checked_subprocess(cmd, tex)
277279
return pngfile

‎requirements/testing/minver.txt

Copy file name to clipboardExpand all lines: requirements/testing/minver.txt
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
cycler==0.10
44
kiwisolver==1.0.1
55
numpy==1.17.0
6+
packaging==20.0
67
pillow==6.2.0
78
pyparsing==2.2.1
89
python-dateutil==2.7

‎setup.py

Copy file name to clipboardExpand all lines: setup.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,7 @@ def make_release_tree(self, base_dir, files):
327327
"cycler>=0.10",
328328
"kiwisolver>=1.0.1",
329329
"numpy>=1.17",
330+
"packaging>=20.0",
330331
"pillow>=6.2.0",
331332
"pyparsing>=2.2.1",
332333
"python-dateutil>=2.7",

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.