From b879301d08d3d8f209da2f89f43ef5b263245cd9 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Thu, 19 Aug 2021 20:50:24 -0400 Subject: [PATCH 1/5] Add Python 3.10 testing. --- .github/workflows/tests.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 84c73e3e3289..b4a1bbbf35fa 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -41,6 +41,11 @@ jobs: python-version: 3.9 extra-requirements: '-r requirements/testing/extra.txt' XVFB_RUN: xvfb-run -a + - os: ubuntu-20.04 + python-version: '3.10-dev' + # Re-add this when extra dependencies have wheels. + # extra-requirements: '-r requirements/testing/extra.txt' + XVFB_RUN: xvfb-run -a - os: macos-latest python-version: 3.8 XVFB_RUN: "" From c2f83ecffeed7b6d1d9dd9cbb814fc389acc614e Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Thu, 19 Aug 2021 20:58:57 -0400 Subject: [PATCH 2/5] Add 3.10 to PyPI classifiers. --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index c72e13623c2d..122456a6a983 100644 --- a/setup.py +++ b/setup.py @@ -304,6 +304,7 @@ def make_release_tree(self, base_dir, files): 'Programming Language :: Python :: 3.7', 'Programming Language :: Python :: 3.8', 'Programming Language :: Python :: 3.9', + 'Programming Language :: Python :: 3.10', 'Topic :: Scientific/Engineering :: Visualization', ], From ce84623c46233c7c10f02f50d1fcc321370e17ed Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 20 Aug 2021 17:04:34 -0400 Subject: [PATCH 3/5] Work around PySide2 incompatibility with Python 3.10. --- lib/matplotlib/backends/backend_qt.py | 24 +++++++++---------- .../backends/qt_editor/_formlayout.py | 10 +++++--- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/lib/matplotlib/backends/backend_qt.py b/lib/matplotlib/backends/backend_qt.py index 97a27a31cb27..c7c498524614 100644 --- a/lib/matplotlib/backends/backend_qt.py +++ b/lib/matplotlib/backends/backend_qt.py @@ -626,9 +626,9 @@ class NavigationToolbar2QT(NavigationToolbar2, QtWidgets.QToolBar): def __init__(self, canvas, parent, coordinates=True): """coordinates: should we show the coordinates on the right?""" QtWidgets.QToolBar.__init__(self, parent) - self.setAllowedAreas( - _enum("QtCore.Qt.ToolBarArea").TopToolBarArea - | _enum("QtCore.Qt.ToolBarArea").TopToolBarArea) + self.setAllowedAreas(QtCore.Qt.ToolBarArea( + _to_int(_enum("QtCore.Qt.ToolBarArea").TopToolBarArea) | + _to_int(_enum("QtCore.Qt.ToolBarArea").BottomToolBarArea))) self.coordinates = coordinates self._actions = {} # mapping of toolitem method names to QActions. @@ -651,9 +651,9 @@ def __init__(self, canvas, parent, coordinates=True): # will resize this label instead of the buttons. if self.coordinates: self.locLabel = QtWidgets.QLabel("", self) - self.locLabel.setAlignment( - _enum("QtCore.Qt.AlignmentFlag").AlignRight - | _enum("QtCore.Qt.AlignmentFlag").AlignVCenter) + self.locLabel.setAlignment(QtCore.Qt.AlignmentFlag( + _to_int(_enum("QtCore.Qt.AlignmentFlag").AlignRight) | + _to_int(_enum("QtCore.Qt.AlignmentFlag").AlignVCenter))) self.locLabel.setSizePolicy(QtWidgets.QSizePolicy( _enum("QtWidgets.QSizePolicy.Policy").Expanding, _enum("QtWidgets.QSizePolicy.Policy").Ignored, @@ -883,13 +883,13 @@ class ToolbarQt(ToolContainerBase, QtWidgets.QToolBar): def __init__(self, toolmanager, parent): ToolContainerBase.__init__(self, toolmanager) QtWidgets.QToolBar.__init__(self, parent) - self.setAllowedAreas( - _enum("QtCore.Qt.ToolBarArea").TopToolBarArea - | _enum("QtCore.Qt.ToolBarArea").TopToolBarArea) + self.setAllowedAreas(QtCore.Qt.ToolBarArea( + _to_int(_enum("QtCore.Qt.ToolBarArea").TopToolBarArea) | + _to_int(_enum("QtCore.Qt.ToolBarArea").BottomToolBarArea))) message_label = QtWidgets.QLabel("") - message_label.setAlignment( - _enum("QtCore.Qt.AlignmentFlag").AlignRight - | _enum("QtCore.Qt.AlignmentFlag").AlignVCenter) + message_label.setAlignment(QtCore.Qt.AlignmentFlag( + _to_int(_enum("QtCore.Qt.AlignmentFlag").AlignRight) | + _to_int(_enum("QtCore.Qt.AlignmentFlag").AlignVCenter))) message_label.setSizePolicy(QtWidgets.QSizePolicy( _enum("QtWidgets.QSizePolicy.Policy").Expanding, _enum("QtWidgets.QSizePolicy.Policy").Ignored, diff --git a/lib/matplotlib/backends/qt_editor/_formlayout.py b/lib/matplotlib/backends/qt_editor/_formlayout.py index 9ca8963e2b23..8c3127bdbeee 100644 --- a/lib/matplotlib/backends/qt_editor/_formlayout.py +++ b/lib/matplotlib/backends/qt_editor/_formlayout.py @@ -48,7 +48,7 @@ from matplotlib import _api, colors as mcolors from .. import qt_compat -from ..qt_compat import QtGui, QtWidgets, QtCore, _enum +from ..qt_compat import QtGui, QtWidgets, QtCore, _enum, _to_int _log = logging.getLogger(__name__) @@ -441,8 +441,12 @@ def __init__(self, data, title="", comment="", # Button box self.bbox = bbox = QtWidgets.QDialogButtonBox( - _enum("QtWidgets.QDialogButtonBox.StandardButton").Ok - | _enum("QtWidgets.QDialogButtonBox.StandardButton").Cancel) + QtWidgets.QDialogButtonBox.StandardButton( + _to_int( + _enum("QtWidgets.QDialogButtonBox.StandardButton").Ok) | + _to_int( + _enum("QtWidgets.QDialogButtonBox.StandardButton").Cancel) + )) self.formwidget.update_buttons.connect(self.update_buttons) if self.apply_callback is not None: apply_btn = bbox.addButton( From 974466f37d4e5744597604e1a94287365459adea Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 20 Aug 2021 18:03:18 -0400 Subject: [PATCH 4/5] Ignore import warnings from gobject-introspection. This is an incompatibility with Python 3.10 that is not fixed there yet. https://gitlab.gnome.org/GNOME/pygobject/-/issues/473 --- lib/matplotlib/testing/conftest.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/matplotlib/testing/conftest.py b/lib/matplotlib/testing/conftest.py index 678825f4a89d..996bfbefef80 100644 --- a/lib/matplotlib/testing/conftest.py +++ b/lib/matplotlib/testing/conftest.py @@ -21,6 +21,9 @@ def pytest_configure(config): ("filterwarnings", "error"), ("filterwarnings", "ignore:.*The py23 module has been deprecated:DeprecationWarning"), + ("filterwarnings", + r"ignore:DynamicImporter.find_spec\(\) not found; " + r"falling back to find_module\(\):ImportWarning"), ]: config.addinivalue_line(key, value) From 7aa119fbc54061ce4164deeba33aeba39012ef2f Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Fri, 20 Aug 2021 18:08:53 -0400 Subject: [PATCH 5/5] Skip Sphinx tests if on Python 3.10. It's not currently compatible, but should be in the next bug fix. --- lib/matplotlib/tests/test_sphinxext.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/tests/test_sphinxext.py b/lib/matplotlib/tests/test_sphinxext.py index 02d56aeedc55..f71c6e32018a 100644 --- a/lib/matplotlib/tests/test_sphinxext.py +++ b/lib/matplotlib/tests/test_sphinxext.py @@ -10,7 +10,8 @@ import pytest -pytest.importorskip('sphinx') +pytest.importorskip('sphinx', + minversion=None if sys.version_info < (3, 10) else '4.1.3') def test_tinypages(tmpdir):