Skip to content

Commit 113fc77

Browse files
authored
Merge pull request #24197 from anntzer/bv
Properly set and inherit backend_version.
2 parents 5fe74c2 + b0db405 commit 113fc77

12 files changed

+18
-26
lines changed

lib/matplotlib/backends/_backend_gtk.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,7 @@
2424
raise ImportError("Gtk-based backends require cairo") from e
2525

2626
_log = logging.getLogger(__name__)
27-
28-
backend_version = "%s.%s.%s" % (
29-
Gtk.get_major_version(), Gtk.get_minor_version(), Gtk.get_micro_version())
30-
31-
# Placeholder
32-
_application = None
27+
_application = None # Placeholder
3328

3429

3530
def _shutdown_application(app):
@@ -305,6 +300,12 @@ def trigger(self, *args):
305300

306301

307302
class _BackendGTK(_Backend):
303+
backend_version = "%s.%s.%s" % (
304+
Gtk.get_major_version(),
305+
Gtk.get_minor_version(),
306+
Gtk.get_micro_version(),
307+
)
308+
308309
@staticmethod
309310
def mainloop():
310311
global _application

lib/matplotlib/backends/_backend_tk.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424

2525

2626
_log = logging.getLogger(__name__)
27-
28-
backend_version = tk.TkVersion
29-
3027
cursord = {
3128
cursors.MOVE: "fleur",
3229
cursors.HAND: "hand2",
@@ -1020,6 +1017,7 @@ def trigger(self, *args):
10201017

10211018
@_Backend.export
10221019
class _BackendTk(_Backend):
1020+
backend_version = tk.TkVersion
10231021
FigureManager = FigureManagerTk
10241022

10251023
@staticmethod

lib/matplotlib/backends/backend_agg.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@
4040
from matplotlib.backends._backend_agg import RendererAgg as _RendererAgg
4141

4242

43-
backend_version = 'v2.2'
44-
45-
4643
def get_hinting_flag():
4744
mapping = {
4845
'default': LOAD_DEFAULT,
@@ -558,5 +555,6 @@ def print_webp(self, filename_or_obj, *, pil_kwargs=None):
558555

559556
@_Backend.export
560557
class _BackendAgg(_Backend):
558+
backend_version = 'v2.2'
561559
FigureCanvas = FigureCanvasAgg
562560
FigureManager = FigureManagerBase

lib/matplotlib/backends/backend_cairo.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@
3434
from matplotlib.transforms import Affine2D
3535

3636

37-
backend_version = cairo.version
38-
39-
4037
def _append_path(ctx, path, transform, clip=None):
4138
for points, code in path.iter_segments(
4239
transform, remove_nans=True, clip=clip):
@@ -548,5 +545,6 @@ def set_context(self, ctx):
548545

549546
@_Backend.export
550547
class _BackendCairo(_Backend):
548+
backend_version = cairo.version
551549
FigureCanvas = FigureCanvasCairo
552550
FigureManager = FigureManagerBase

lib/matplotlib/backends/backend_gtk3.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
_BackendGTK, _FigureManagerGTK, _NavigationToolbar2GTK,
3131
TimerGTK as TimerGTK3,
3232
)
33-
from ._backend_gtk import backend_version # noqa: F401 # pylint: disable=W0611
3433

3534

3635
_log = logging.getLogger(__name__)

lib/matplotlib/backends/backend_gtk4.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
_BackendGTK, _FigureManagerGTK, _NavigationToolbar2GTK,
2929
TimerGTK as TimerGTK4,
3030
)
31-
from ._backend_gtk import backend_version # noqa: F401 # pylint: disable=W0611
3231

3332

3433
class FigureCanvasGTK4(FigureCanvasBase, Gtk.DrawingArea):

lib/matplotlib/backends/backend_ps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,8 @@
3333
from matplotlib.backends.backend_mixed import MixedModeRenderer
3434
from . import _backend_pdf_ps
3535

36-
_log = logging.getLogger(__name__)
3736

38-
backend_version = 'Level II'
37+
_log = logging.getLogger(__name__)
3938
debugPS = False
4039

4140

@@ -1369,4 +1368,5 @@ def pstoeps(tmpfile, bbox=None, rotated=False):
13691368

13701369
@_Backend.export
13711370
class _BackendPS(_Backend):
1371+
backend_version = 'Level II'
13721372
FigureCanvas = FigureCanvasPS

lib/matplotlib/backends/backend_qt.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
)
2121

2222

23-
backend_version = __version__
24-
2523
# SPECIAL_KEYS are Qt::Key that do *not* return their Unicode name
2624
# instead they have manually specified names.
2725
SPECIAL_KEYS = {
@@ -1006,6 +1004,7 @@ def trigger(self, *args, **kwargs):
10061004

10071005
@_Backend.export
10081006
class _BackendQT(_Backend):
1007+
backend_version = __version__
10091008
FigureCanvas = FigureCanvasQT
10101009
FigureManager = FigureManagerQT
10111010

lib/matplotlib/backends/backend_qt5.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
from .backend_qt import ( # noqa
7-
backend_version, SPECIAL_KEYS,
7+
SPECIAL_KEYS,
88
# Public API
99
cursord, _create_qApp, _BackendQT, TimerQT, MainWindow, FigureCanvasQT,
1010
FigureManagerQT, ToolbarQt, NavigationToolbar2QT, SubplotToolQt,

lib/matplotlib/backends/backend_qt5agg.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
backends._QT_FORCE_QT5_BINDING = True
77
from .backend_qtagg import ( # noqa: F401, E402 # pylint: disable=W0611
88
_BackendQTAgg, FigureCanvasQTAgg, FigureManagerQT, NavigationToolbar2QT,
9-
backend_version, FigureCanvasAgg, FigureCanvasQT
10-
)
9+
FigureCanvasAgg, FigureCanvasQT)
1110

1211

1312
@_BackendQTAgg.export

lib/matplotlib/backends/backend_qtagg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from .backend_agg import FigureCanvasAgg
1212
from .backend_qt import QtCore, QtGui, _BackendQT, FigureCanvasQT
1313
from .backend_qt import ( # noqa: F401 # pylint: disable=W0611
14-
FigureManagerQT, NavigationToolbar2QT, backend_version)
14+
FigureManagerQT, NavigationToolbar2QT)
1515

1616

1717
class FigureCanvasQTAgg(FigureCanvasAgg, FigureCanvasQT):

lib/matplotlib/backends/backend_svg.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@
2424
from matplotlib import _path
2525
from matplotlib.transforms import Affine2D, Affine2DBase
2626

27+
2728
_log = logging.getLogger(__name__)
2829

29-
backend_version = mpl.__version__
3030

3131
# ----------------------------------------------------------------------
3232
# SimpleXMLWriter class
@@ -1408,4 +1408,5 @@ def draw(self):
14081408

14091409
@_Backend.export
14101410
class _BackendSVG(_Backend):
1411+
backend_version = mpl.__version__
14111412
FigureCanvas = FigureCanvasSVG

0 commit comments

Comments
 (0)