|
2 | 2 | Qt binding and backend selector. |
3 | 3 |
|
4 | 4 | The selection logic is as follows: |
5 | | -- if any of PyQt6, PySide6, PyQt5, or PySide2 have already been |
| 5 | +- if any of PyQt6, PySide6, or PyQt5 have already been |
6 | 6 | imported (checked in that order), use it; |
7 | 7 | - otherwise, if the QT_API environment variable (used by Enthought) is set, use |
8 | 8 | it to determine which binding to use; |
|
23 | 23 | QT_API_PYQT6 = "PyQt6" |
24 | 24 | QT_API_PYSIDE6 = "PySide6" |
25 | 25 | QT_API_PYQT5 = "PyQt5" |
26 | | -QT_API_PYSIDE2 = "PySide2" |
27 | 26 | QT_API_ENV = os.environ.get("QT_API") |
28 | 27 | if QT_API_ENV is not None: |
29 | 28 | QT_API_ENV = QT_API_ENV.lower() |
30 | 29 | _ETS = { # Mapping of QT_API_ENV to requested binding. |
31 | 30 | "pyqt6": QT_API_PYQT6, "pyside6": QT_API_PYSIDE6, |
32 | | - "pyqt5": QT_API_PYQT5, "pyside2": QT_API_PYSIDE2, |
| 31 | + "pyqt5": QT_API_PYQT5, |
33 | 32 | } |
34 | 33 | # First, check if anything is already imported. |
35 | 34 | if sys.modules.get("PyQt6.QtCore"): |
|
38 | 37 | QT_API = QT_API_PYSIDE6 |
39 | 38 | elif sys.modules.get("PyQt5.QtCore"): |
40 | 39 | QT_API = QT_API_PYQT5 |
41 | | -elif sys.modules.get("PySide2.QtCore"): |
42 | | - QT_API = QT_API_PYSIDE2 |
43 | 40 | # Otherwise, check the QT_API environment variable (from Enthought). This can |
44 | 41 | # only override the binding, not the backend (in other words, we check that the |
45 | 42 | # requested backend actually matches). Use _get_backend_or_none to avoid |
46 | 43 | # triggering backend resolution (which can result in a partially but |
47 | 44 | # incompletely imported backend_qt5). |
48 | 45 | elif (mpl.rcParams._get_backend_or_none() or "").lower().startswith("qt5"): |
49 | | - if QT_API_ENV in ["pyqt5", "pyside2"]: |
| 46 | + if QT_API_ENV == "pyqt5": |
50 | 47 | QT_API = _ETS[QT_API_ENV] |
51 | 48 | else: |
52 | 49 | _QT_FORCE_QT5_BINDING = True # noqa: F811 |
@@ -92,33 +89,22 @@ def _isdeleted(obj): return not shiboken6.isValid(obj) |
92 | 89 | QtCore.Property = QtCore.pyqtProperty |
93 | 90 | _isdeleted = sip.isdeleted |
94 | 91 | _to_int = int |
95 | | - elif QT_API == QT_API_PYSIDE2: |
96 | | - from PySide2 import QtCore, QtGui, QtWidgets, QtSvg, __version__ |
97 | | - try: |
98 | | - from PySide2 import shiboken2 |
99 | | - except ImportError: |
100 | | - import shiboken2 |
101 | | - def _isdeleted(obj): |
102 | | - return not shiboken2.isValid(obj) |
103 | | - _to_int = int |
104 | 92 | else: |
105 | 93 | raise AssertionError(f"Unexpected QT_API: {QT_API}") |
106 | 94 |
|
107 | 95 |
|
108 | | -if QT_API in [QT_API_PYQT6, QT_API_PYQT5, QT_API_PYSIDE6, QT_API_PYSIDE2]: |
| 96 | +if QT_API in [QT_API_PYQT6, QT_API_PYQT5, QT_API_PYSIDE6]: |
109 | 97 | _setup_pyqt5plus() |
110 | 98 | elif QT_API is None: # See above re: dict.__getitem__. |
111 | 99 | if _QT_FORCE_QT5_BINDING: |
112 | 100 | _candidates = [ |
113 | 101 | (_setup_pyqt5plus, QT_API_PYQT5), |
114 | | - (_setup_pyqt5plus, QT_API_PYSIDE2), |
115 | 102 | ] |
116 | 103 | else: |
117 | 104 | _candidates = [ |
118 | 105 | (_setup_pyqt5plus, QT_API_PYQT6), |
119 | 106 | (_setup_pyqt5plus, QT_API_PYSIDE6), |
120 | 107 | (_setup_pyqt5plus, QT_API_PYQT5), |
121 | | - (_setup_pyqt5plus, QT_API_PYSIDE2), |
122 | 108 | ] |
123 | 109 | for _setup, QT_API in _candidates: |
124 | 110 | try: |
|
0 commit comments