8000 Backport PR #24197: Properly set and inherit backend_version. · meeseeksmachine/matplotlib@4b7d84a · GitHub
[go: up one dir, main page]

Skip to content

Commit 4b7d84a

Browse files
QuLogicmeeseeksmachine
authored andcommitted
Backport PR matplotlib#24197: Properly set and inherit backend_version.
1 parent 28087a2 commit 4b7d84a

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(_Backen 10000 d):
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",
@@ -1027,6 +1024,7 @@ def trigger(self, *args):
10271024

10281025
@_Backend.export
10291026
class _BackendTk(_Backend):
1027+
backend_version = tk.TkVersion
10301028
FigureManager = FigureManagerTk
10311029

10321030
@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,
@@ -563,5 +560,6 @@ def print_webp(self, filename_or_obj, *, pil_kwargs=None):
563560

564561
@_Backend.export
565562
class _BackendAgg(_Backend):
563+
backend_version = 'v2.2'
566564
FigureCanvas = FigureCanvasAgg
567565
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
@@ -31,7 +31,6 @@
3131
_BackendGTK, _FigureManagerGTK, _NavigationToolbar2GTK,
3232
TimerGTK as TimerGTK3,
3333
)
34-
from ._backend_gtk import backend_version # noqa: F401 # pylint: disable=W0611
3534

3635

3736
_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

@@ -1364,4 +1363,5 @@ def pstoeps(tmpfile, bbox=None, rotated=False):
13641363

13651364
@_Backend.export
13661365
class _BackendPS(_Backend):
1366+
backend_version = 'Level II'
13671367
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 = {
@@ -1013, FCDC 6 +1011,7 @@ def trigger(self, *args, **kwargs):
10131011

10141012
@_Backend.export
10151013
class _BackendQT(_Backend):
1014+
backend_version = __version__
10161015
FigureCanvas = FigureCanvasQT
10171016
FigureManager = FigureManagerQT
10181017

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

0 commit comments

Comments
 (0)
0