Handle new matplotlib versions (#1791)

Fixes: https://github.com/microsoft/debugpy/issues/1623
This commit is contained in:
Gary Miguel 2025-01-06 09:47:23 -08:00 committed by GitHub
parent 24aa6a5f8e
commit cc85ca8e01
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -53,9 +53,29 @@ def find_gui_and_backend():
return gui, backend
def _get_major_version(module):
return int(module.__version__.split('.')[0])
def _get_minor_version(module):
return int(module.__version__.split('.')[1])
def is_interactive_backend(backend):
"""Check if backend is interactive"""
matplotlib = sys.modules["matplotlib"]
new_api_version = (3, 9)
installed_version = (
_get_major_version(matplotlib),
_get_minor_version(matplotlib)
)
if installed_version >= new_api_version:
interactive_bk = matplotlib.backends.backend_registry.list_builtin(
matplotlib.backends.BackendFilter.INTERACTIVE)
non_interactive_bk = matplotlib.backends.backend_registry.list_builtin(
matplotlib.backends.BackendFilter.NON_INTERACTIVE)
else:
from matplotlib.rcsetup import interactive_bk, non_interactive_bk # @UnresolvedImport
if backend in interactive_bk: