From 86fe3e3fcc2c258883c9b22bae95d509dc796216 Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Tue, 23 Apr 2024 12:02:12 -0500 Subject: [PATCH 01/10] Update Changelog --- CHANGELOG.md | 68 +++++++++------------------------------------------- 1 file changed, 11 insertions(+), 57 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0ea2160d..fa6747c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,16 @@ # History of changes +## Version 3.0.0b5 (2024-04-23) + +### Pull Requests Merged + +* [PR 481](https://github.com/spyder-ide/spyder-kernels/pull/481) - PR: Allow magic to edit locals while debugging, by [@impact27](https://github.com/impact27) +* [PR 480](https://github.com/spyder-ide/spyder-kernels/pull/480) - PR: Save faulthandler files under `xdg_data_home/spyder` on Linux, by [@ccordoba12](https://github.com/ccordoba12) + +In this release 2 pull requests were closed. + +---- + ## Version 3.0.0b4 (2024-02-08) ### Pull Requests Merged @@ -8,10 +19,8 @@ In this release 1 pull request was closed. - ---- - ## Version 3.0.0b3 (2023-12-18) ### Pull Requests Merged @@ -22,10 +31,8 @@ In this release 1 pull request was closed. In this release 3 pull requests were closed. - ---- - ## Version 3.0.0b2 (2023-08-22) ### Pull Requests Merged @@ -82,7 +89,6 @@ In this release 2 issues were closed. In this release 25 pull requests were closed. - ---- ## Version 2.5.1 (2024-02-28) @@ -91,10 +97,8 @@ In this release 25 pull requests were closed. * [PR 479](https://github.com/spyder-ide/spyder-kernels/pull/479) - PR: Fix hangs with Maplotlib interactive backends, by [@ccordoba12](https://github.com/ccordoba12) - ---- - ## Version 2.5.0 (2023-11-06) ### New features @@ -114,10 +118,8 @@ In this release 25 pull requests were closed. In this release 6 pull requests were closed. - ---- - ## Version 2.4.4 (2023-06-29) ### Issues Closed @@ -135,10 +137,8 @@ In this release 1 issue was closed. In this release 4 pull requests were closed. - ---- - ## Version 2.4.3 (2023-04-02) ### Issues Closed @@ -159,10 +159,8 @@ In this release 1 issue was closed. In this release 7 pull requests were closed. - ---- - ## Version 2.4.2 (2023-01-17) ### Issues Closed @@ -178,10 +176,8 @@ In this release 1 issue was closed. In this release 2 pull requests were closed. - ---- - ## Version 2.4.1 (2022-12-29) ### Issues Closed @@ -196,10 +192,8 @@ In this release 1 issue was closed. In this release 1 pull request was closed. - ---- - ## Version 2.4.0 (2022-11-02) ### New features @@ -220,10 +214,8 @@ In this release 1 pull request was closed. In this release 8 pull requests were closed. - ---- - ## Version 2.3.3 (2022-08-28) ### Issues Closed @@ -239,10 +231,8 @@ In this release 1 issue was closed. In this release 2 pull requests were closed. - ---- - ## Version 2.3.2 (2022-07-06) ### Issues Closed @@ -264,10 +254,8 @@ In this release 1 issue was closed. In this release 8 pull requests were closed. - ---- - ## Version 2.3.1 (2022-05-21) ### Pull Requests Merged @@ -278,10 +266,8 @@ In this release 8 pull requests were closed. In this release 3 pull requests were closed. - --- - ## Version 2.3.0 (2022-03-30) ### New features @@ -313,10 +299,8 @@ In this release 4 issues were closed. In this release 10 pull requests were closed. - ---- - ## Version 2.2.1 (2022-01-13) ### Issues Closed @@ -349,10 +333,8 @@ In this release 4 issues were closed. In this release 16 pull requests were closed. - ---- - ## Version 2.2.0 (2021-11-22) ### New features @@ -384,10 +366,8 @@ In this release 3 issues were closed. In this release 10 pull requests were closed. - ---- - ## Version 2.1.3 (2021-10-02) ### Pull Requests Merged @@ -396,10 +376,8 @@ In this release 10 pull requests were closed. In this release 1 pull request was closed. - ---- - ## Version 2.1.2 (2021-09-28) ### Pull Requests Merged @@ -409,10 +387,8 @@ In this release 1 pull request was closed. In this release 2 pull requests were closed. - ---- - ## Version 2.1.1 (2021-09-01) ### Pull Requests Merged @@ -424,10 +400,8 @@ In this release 2 pull requests were closed. In this release 4 pull requests were closed. - ---- - ## Version 2.1.0 (2021-07-31) ### New features @@ -452,10 +426,8 @@ In this release 1 issue was closed. In this release 5 pull requests were closed. - ---- - ## Version 2.0.5 (2021-07-03) ### Pull Requests Merged @@ -464,10 +436,8 @@ In this release 5 pull requests were closed. In this release 1 pull request was closed. - ---- - ## Version 2.0.4 (2021-06-10) ### Issues Closed @@ -488,10 +458,8 @@ In this release 1 issue was closed. In this release 7 pull requests were closed. - ---- - ## Version 2.0.3 (2021-05-15) ### Pull Requests Merged @@ -500,10 +468,8 @@ In this release 7 pull requests were closed. In this release 1 pull request was closed. - ---- - ## Version 2.0.2 (2021-05-02) ### Pull Requests Merged @@ -514,18 +480,14 @@ In this release 1 pull request was closed. In this release 3 pull requests were closed. - ---- - ## Version 2.0.1 (2021-04-02) * This release also contains all fixes present in version 1.10.3 - ---- - ## Version 2.0.0 (2021-04-01) ### New features @@ -539,10 +501,8 @@ In this release 3 pull requests were closed. In this release 2 pull requests were closed. - ---- - ## Version 1.10.3 (2021-04-02) ### Pull Requests Merged @@ -551,10 +511,8 @@ In this release 2 pull requests were closed. In this release 1 pull request was closed. - ---- - ## Version 1.10.2 (2021-02-21) ### Pull Requests Merged @@ -567,10 +525,8 @@ In this release 1 pull request was closed. In this release 5 pull requests were closed. - ---- - ## Version 1.10.1 (2020-12-18) ### Issues Closed @@ -594,10 +550,8 @@ In this release 2 issues were closed. In this release 9 pull requests were closed. - ---- - ## Version 1.10.0 (2020-11-08) ### New features From 9903a360405c9d1c5405c49d55c2fe06e18e9483 Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Tue, 23 Apr 2024 12:04:12 -0500 Subject: [PATCH 02/10] Release 3.0.0b5 --- spyder_kernels/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spyder_kernels/_version.py b/spyder_kernels/_version.py index 788cf5f4..2ce2e4d2 100644 --- a/spyder_kernels/_version.py +++ b/spyder_kernels/_version.py @@ -8,5 +8,5 @@ """Version File.""" -VERSION_INFO = (3, 0, 0, 'dev0') +VERSION_INFO = (3, 0, '0b5') __version__ = '.'.join(map(str, VERSION_INFO)) From 6110b633226183eba4e95a6d20ca9fe83e57493a Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Tue, 23 Apr 2024 12:07:01 -0500 Subject: [PATCH 03/10] Back to work --- spyder_kernels/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spyder_kernels/_version.py b/spyder_kernels/_version.py index 2ce2e4d2..788cf5f4 100644 --- a/spyder_kernels/_version.py +++ b/spyder_kernels/_version.py @@ -8,5 +8,5 @@ """Version File.""" -VERSION_INFO = (3, 0, '0b5') +VERSION_INFO = (3, 0, 0, 'dev0') __version__ = '.'.join(map(str, VERSION_INFO)) From bf782e0c4a39271aad5b15c51ac4e801d210a7aa Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Mon, 29 Apr 2024 19:57:31 -0500 Subject: [PATCH 04/10] Comms: Avoid unnecessary messages from set_configuration --- spyder_kernels/comms/utils.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spyder_kernels/comms/utils.py b/spyder_kernels/comms/utils.py index dc6b8c99..00332349 100644 --- a/spyder_kernels/comms/utils.py +++ b/spyder_kernels/comms/utils.py @@ -53,7 +53,13 @@ def is_benign_message(self, message): # Fixes spyder-ide/spyder-kernels#343 'DeprecationWarning', # Fixes spyder-ide/spyder-kernels#365 - 'IOStream.flush timed out' + 'IOStream.flush timed out', + # Avoid unnecessary messages from set_configuration when changing + # Matplotlib options. + "Warning: Cannot change to a different GUI toolkit", + "%pylab is deprecated", + "Populating the interactive namespace", + "\n" ] return any([msg in message for msg in benign_messages]) From 2bc4687625c5ad9d1a5e28e6578ac16a789b371b Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Thu, 2 May 2024 13:12:03 -0500 Subject: [PATCH 05/10] Kernel: Simplify the way we get the Matplotlib interactive backend - It seems the current way broke in one of the recent IPykernel updates. - Also, make a small fix to correctly report the Inline backend after enabling it in IPython 8.24. --- spyder_kernels/console/kernel.py | 46 +++++++++----------------------- spyder_kernels/console/shell.py | 15 ++++++++++- 2 files changed, 27 insertions(+), 34 deletions(-) diff --git a/spyder_kernels/console/kernel.py b/spyder_kernels/console/kernel.py index 9c837f62..2d3d5eaa 100644 --- a/spyder_kernels/console/kernel.py +++ b/spyder_kernels/console/kernel.py @@ -23,7 +23,7 @@ # Third-party imports from ipykernel.ipkernel import IPythonKernel -from ipykernel import eventloops, get_connection_info +from ipykernel import get_connection_info from traitlets.config.loader import LazyConfigValue import zmq from zmq.utils.garbage import gc @@ -76,6 +76,9 @@ def __init__(self, *args, **kwargs): # Socket to signal shell_stream locally self.loopback_socket = None + # To track the interactive backend + self.interactive_backend = None + @property def kernel_info(self): # Used for checking correct version by spyder @@ -505,43 +508,20 @@ def get_mpl_interactive_backend(self): Get current Matplotlib interactive backend. This is different from the current backend because, for instance, the - user can set first the Qt5 backend, then the Inline one. In that case, - the current backend is Inline, but the current interactive one is Qt5, + user can set first the Qt backend, then the Inline one. In that case, + the current backend is Inline, but the current interactive one is Qt, and this backend can't be changed without a kernel restart. """ - # Mapping from frameworks to backend names. - mapping = { - 'qt': 'QtAgg', - 'tk': 'TkAgg', - 'macosx': 'MacOSX' - } - - # --- Get interactive framework - framework = None - - # Detect if there is a graphical framework running by checking the - # eventloop function attached to the kernel.eventloop attribute (see - # `ipykernel.eventloops.enable_gui` for context). - loop_func = self.eventloop - - if loop_func is not None: - if loop_func == eventloops.loop_tk: - framework = 'tk' - elif loop_func == eventloops.loop_qt5: - framework = 'qt' - elif loop_func == eventloops.loop_cocoa: - framework = 'macosx' - else: - # Spyder doesn't handle other backends - framework = 'other' + # Backends that Spyder can handle + recognized_backends = {'qt', 'tk', 'macosx'} # --- Return backend according to framework - if framework is None: - # Since no interactive backend has been set yet, this is - # equivalent to having the inline one. + if self.interactive_backend is None: + # Since no interactive backend has been set yet, this is equivalent + # to having the inline one. return 'inline' - elif framework in mapping: - return MPL_BACKENDS_TO_SPYDER[mapping[framework]] + elif self.interactive_backend in recognized_backends: + return self.interactive_backend else: # This covers the case of other backends (e.g. Wx or Gtk) # which users can set interactively with the %matplotlib diff --git a/spyder_kernels/console/shell.py b/spyder_kernels/console/shell.py index 5256bb67..48cecaf3 100644 --- a/spyder_kernels/console/shell.py +++ b/spyder_kernels/console/shell.py @@ -87,7 +87,19 @@ def enable_matplotlib(self, gui=None): """Enable matplotlib.""" if gui is None or gui.lower() == "auto": gui = automatic_backend() - gui, backend = super(SpyderShell, self).enable_matplotlib(gui) + + enabled_gui, backend = super().enable_matplotlib(gui) + + # This is necessary for IPython 8.24+, which returns None after + # enabling the Inline backend. + if enabled_gui is None and gui == "inline": + enabled_gui = "inline" + gui = enabled_gui + + # To easily track the current interactive backend + if self.kernel.interactive_backend is None: + self.kernel.interactive_backend = gui if gui != "inline" else None + if self.update_gui_frontend: try: self.kernel.frontend_call( @@ -95,6 +107,7 @@ def enable_matplotlib(self, gui=None): ).update_matplotlib_gui(gui) except Exception: pass + return gui, backend # --- For Pdb namespace integration From d060921d561aa637509179692a6cd1b38bda35d7 Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Tue, 14 May 2024 20:23:47 -0500 Subject: [PATCH 06/10] Testing: Run test_get_interactive_backend again on Mac - The latest changes to detect interactive backends fix it. - Only Skip it for the Qt backend on CIs because it fails there. --- spyder_kernels/console/tests/test_console_kernel.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spyder_kernels/console/tests/test_console_kernel.py b/spyder_kernels/console/tests/test_console_kernel.py index a9564feb..6cb81741 100644 --- a/spyder_kernels/console/tests/test_console_kernel.py +++ b/spyder_kernels/console/tests/test_console_kernel.py @@ -1143,14 +1143,16 @@ def test_locals_globals_in_pdb(kernel): reason="Doesn't work with pip packages") @pytest.mark.skipif( sys.version_info[:2] < (3, 9), - reason="Too flaky in Python 3.7/8 and doesn't work in older versions") -@pytest.mark.skipif(sys.platform == 'darwin', reason="Fails on Mac") + reason="Too flaky in Python 3.8 and doesn't work in older versions") def test_get_interactive_backend(backend): """ Test that we correctly get the interactive backend set in the kernel. """ - cmd = "from spyder_kernels.console import start; start.main()" + # This test passes locally but fails on CIs. Don't know why. + if sys.platform == "darwin" and backend == "qt" and os.environ.get('CI'): + return + cmd = "from spyder_kernels.console import start; start.main()" with setup_kernel(cmd) as client: # Set backend if backend is not None: From 8748b787f297396ac8a26b69d4a1661c2b48b145 Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Tue, 14 May 2024 21:20:36 -0500 Subject: [PATCH 07/10] Update Changelog --- CHANGELOG.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa6747c1..851f7c2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # History of changes +## Version 3.0.0b6 (2024-05-15) + +### Issues Closed + +* [Issue 457](https://github.com/spyder-ide/spyder-kernels/issues/457) - Detecting the interactive backend started to fail on Mac in master ([PR 486](https://github.com/spyder-ide/spyder-kernels/pull/486) by [@ccordoba12](https://github.com/ccordoba12)) + +In this release 1 issue was closed. + +### Pull Requests Merged + +* [PR 486](https://github.com/spyder-ide/spyder-kernels/pull/486) - PR: Run `test_get_interactive_backend` again on Mac, by [@ccordoba12](https://github.com/ccordoba12) ([457](https://github.com/spyder-ide/spyder-kernels/issues/457)) +* [PR 485](https://github.com/spyder-ide/spyder-kernels/pull/485) - PR: Fix Matplotlib interactive backend detection, by [@ccordoba12](https://github.com/ccordoba12) + +In this release 2 pull requests were closed. + +---- + ## Version 3.0.0b5 (2024-04-23) ### Pull Requests Merged From 662cd5926f4e6848f9c8ec43a827d87319fc714d Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Tue, 14 May 2024 21:22:24 -0500 Subject: [PATCH 08/10] Release 3.0.0b6 --- spyder_kernels/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spyder_kernels/_version.py b/spyder_kernels/_version.py index 788cf5f4..466f7d48 100644 --- a/spyder_kernels/_version.py +++ b/spyder_kernels/_version.py @@ -8,5 +8,5 @@ """Version File.""" -VERSION_INFO = (3, 0, 0, 'dev0') +VERSION_INFO = (3, 0, '0b6') __version__ = '.'.join(map(str, VERSION_INFO)) From 09c370aab411c954f869649279481636f666098b Mon Sep 17 00:00:00 2001 From: Carlos Cordoba Date: Tue, 14 May 2024 21:27:09 -0500 Subject: [PATCH 09/10] Back to work --- spyder_kernels/_version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spyder_kernels/_version.py b/spyder_kernels/_version.py index 466f7d48..788cf5f4 100644 --- a/spyder_kernels/_version.py +++ b/spyder_kernels/_version.py @@ -8,5 +8,5 @@ """Version File.""" -VERSION_INFO = (3, 0, '0b6') +VERSION_INFO = (3, 0, 0, 'dev0') __version__ = '.'.join(map(str, VERSION_INFO)) From 9b2f5a851c467537675dcc694a164ce05128e882 Mon Sep 17 00:00:00 2001 From: Ryan Clary <9618975+mrclary@users.noreply.github.com> Date: Mon, 20 May 2024 10:59:57 -0700 Subject: [PATCH 10/10] Matplotlib get_backend returns lowercase in version >=3.9.0. Also, inline backend is returned as "inline" instead of "modluel://..." --- spyder_kernels/console/kernel.py | 4 ++-- spyder_kernels/utils/mpl.py | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/spyder_kernels/console/kernel.py b/spyder_kernels/console/kernel.py index 306d2afa..d626ca62 100644 --- a/spyder_kernels/console/kernel.py +++ b/spyder_kernels/console/kernel.py @@ -382,7 +382,7 @@ def get_matplotlib_backend(self): """Get current matplotlib backend.""" try: import matplotlib - return MPL_BACKENDS_TO_SPYDER[matplotlib.get_backend()] + return MPL_BACKENDS_TO_SPYDER[matplotlib.get_backend().lower()] except Exception: return None @@ -428,7 +428,7 @@ def get_mpl_interactive_backend(self): # equivalent to having the inline one. return 0 elif framework in mapping: - return MPL_BACKENDS_TO_SPYDER[mapping[framework]] + return MPL_BACKENDS_TO_SPYDER[mapping[framework].lower()] else: # This covers the case of other backends (e.g. Wx or Gtk) # which users can set interactively with the %matplotlib diff --git a/spyder_kernels/utils/mpl.py b/spyder_kernels/utils/mpl.py index 7927e49d..46b52607 100644 --- a/spyder_kernels/utils/mpl.py +++ b/spyder_kernels/utils/mpl.py @@ -27,11 +27,12 @@ # Mapping of matlotlib backends options to Spyder MPL_BACKENDS_TO_SPYDER = { - inline_backend: 0, - 'Qt5Agg': 2, - 'QtAgg': 2, # For Matplotlib 3.5+ - 'TkAgg': 3, - 'MacOSX': 4, + 'inline': 0, # For Matplotlib >=3.9 + inline_backend: 0, # For Matplotlib <3.9 + 'qt5agg': 2, + 'qtagg': 2, # For Matplotlib 3.5+ + 'tkagg': 3, + 'macosx': 4, }