From 3d037175c3ae4bb20f1366a6e5446ae064ed6306 Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Fri, 11 Oct 2024 16:40:24 -0500 Subject: [PATCH 1/2] git subrepo pull --remote=https://github.com/ccordoba12/spyder-kernels.git --branch=fix-registering-inline-backend --update --force external-deps/spyder-kernels subrepo: subdir: "external-deps/spyder-kernels" merged: "d8855d4fc2" upstream: origin: "https://github.com/ccordoba12/spyder-kernels.git" branch: "fix-registering-inline-backend" commit: "d8855d4fc2" git-subrepo: version: "0.4.9" origin: "https://github.com/ingydotnet/git-subrepo" commit: "ea10886" --- external-deps/spyder-kernels/.gitrepo | 8 +++--- .../spyder_kernels/console/shell.py | 27 +++++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/external-deps/spyder-kernels/.gitrepo b/external-deps/spyder-kernels/.gitrepo index f726b52bc9f..6e69bf03685 100644 --- a/external-deps/spyder-kernels/.gitrepo +++ b/external-deps/spyder-kernels/.gitrepo @@ -4,9 +4,9 @@ ; git-subrepo command. See https://github.com/ingydotnet/git-subrepo#readme ; [subrepo] - remote = https://github.com/spyder-ide/spyder-kernels.git - branch = master - commit = 705618596160a1d65a7a0fc71cec1cfc41fbcaeb - parent = 3852ec47717cd061a2b9719501a5b5e1f9571f18 + remote = https://github.com/ccordoba12/spyder-kernels.git + branch = fix-registering-inline-backend + commit = d8855d4fc26f511352795fc520a62e0afefe767d + parent = 565e9b3fd14a2e7d22d205cc4d13ec2ba428c7ed method = merge cmdver = 0.4.9 diff --git a/external-deps/spyder-kernels/spyder_kernels/console/shell.py b/external-deps/spyder-kernels/spyder_kernels/console/shell.py index d2d32a85f11..3e9224c9df6 100644 --- a/external-deps/spyder-kernels/spyder_kernels/console/shell.py +++ b/external-deps/spyder-kernels/spyder_kernels/console/shell.py @@ -101,6 +101,33 @@ def enable_matplotlib(self, gui=None): enabled_gui = "inline" gui = enabled_gui + # Check if the inline backend is registered. It should be at this + # point, but sometimes that can fail due to a mismatch between + # the installed versions of IPython, matplotlib and matplotlib-inline. + # Fixes spyder-ide/spyder#22420. + if gui == "inline": + is_inline_registered = False + + # The flush_figures callback should be listed as a post_execute + # event if the backend was registered successfully. + for event in self.events.callbacks["post_execute"]: + if "matplotlib_inline.backend_inline.flush_figures" in repr( + event + ): + is_inline_registered = True + break + + # Manually register the backend in case it wasn't + if not is_inline_registered: + from IPython.core.pylabtools import activate_matplotlib + from matplotlib_inline.backend_inline import ( + configure_inline_support + ) + + backend = "module://matplotlib_inline.backend_inline" + activate_matplotlib(backend) + configure_inline_support(self, backend) + # To easily track the current interactive backend if self.kernel.interactive_backend is None: self.kernel.interactive_backend = gui if gui != "inline" else None From a02d71396d02e1fe52cd20007b92936145272f54 Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Fri, 11 Oct 2024 19:23:18 -0500 Subject: [PATCH 2/2] git subrepo pull (merge) --remote=https://github.com/spyder-ide/spyder-kernels.git --branch=master --update --force external-deps/spyder-kernels subrepo: subdir: "external-deps/spyder-kernels" merged: "f9fc2f6217" upstream: origin: "https://github.com/spyder-ide/spyder-kernels.git" branch: "master" commit: "f9fc2f6217" git-subrepo: version: "0.4.9" origin: "https://github.com/ingydotnet/git-subrepo" commit: "ea10886" [ci skip] --- external-deps/spyder-kernels/.gitrepo | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/external-deps/spyder-kernels/.gitrepo b/external-deps/spyder-kernels/.gitrepo index 6e69bf03685..67bef785e7c 100644 --- a/external-deps/spyder-kernels/.gitrepo +++ b/external-deps/spyder-kernels/.gitrepo @@ -4,9 +4,9 @@ ; git-subrepo command. See https://github.com/ingydotnet/git-subrepo#readme ; [subrepo] - remote = https://github.com/ccordoba12/spyder-kernels.git - branch = fix-registering-inline-backend - commit = d8855d4fc26f511352795fc520a62e0afefe767d - parent = 565e9b3fd14a2e7d22d205cc4d13ec2ba428c7ed + remote = https://github.com/spyder-ide/spyder-kernels.git + branch = master + commit = f9fc2f62179a98cf582b44306a9f9225506ec532 + parent = 3d037175c3ae4bb20f1366a6e5446ae064ed6306 method = merge cmdver = 0.4.9