From aa945bbdd23c244a8a1097ef0001413ef7c2d5ce Mon Sep 17 00:00:00 2001 From: Quentin Peter Date: Sun, 17 Sep 2023 18:28:40 +0200 Subject: [PATCH 1/2] disable autoreload --- .../spyder_kernels/console/kernel.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/external-deps/spyder-kernels/spyder_kernels/console/kernel.py b/external-deps/spyder-kernels/spyder_kernels/console/kernel.py index 81dad3916d4..7d4ac1075cb 100644 --- a/external-deps/spyder-kernels/spyder_kernels/console/kernel.py +++ b/external-deps/spyder-kernels/spyder_kernels/console/kernel.py @@ -631,7 +631,8 @@ def set_configuration(self, dic): elif key == "pdb": self.shell.set_pdb_configuration(value) elif key == "faulthandler": - ret[key] = self.enable_faulthandler() + if value: + ret[key] = self.enable_faulthandler() elif key == "special_kernel": ret[key] = self.set_special_kernel(value) elif key == "color scheme": @@ -647,9 +648,10 @@ def set_configuration(self, dic): elif key == "update_gui": self.shell.update_gui_frontend = value elif key == "wurlitzer": - self._load_wurlitzer() + if value: + self._load_wurlitzer() elif key == "autoreload_magic": - self._load_autoreload_magic() + self._autoreload_magic(value) return ret def set_color_scheme(self, color_scheme): @@ -987,11 +989,14 @@ def set_sympy_forecolor(self, background_color='dark'): pass # --- Others - def _load_autoreload_magic(self): + def _autoreload_magic(self, enable): """Load %autoreload magic.""" try: + value = "2" + if not enable: + value = "0" self.shell.run_line_magic('reload_ext', 'autoreload') - self.shell.run_line_magic('autoreload', '2') + self.shell.run_line_magic('autoreload', value) except Exception: pass From c3fb452f18c6b330c06175270f2ed0eaa4feb195 Mon Sep 17 00:00:00 2001 From: Quentin Peter Date: Mon, 18 Sep 2023 18:21:22 +0200 Subject: [PATCH 2/2] disable autoreload --- .../spyder_kernels/console/kernel.py | 11 +++++----- .../spyder_kernels/console/start.py | 4 +--- spyder/config/main.py | 1 + spyder/plugins/ipythonconsole/confpage.py | 22 ++++++++++++++++++- .../plugins/ipythonconsole/widgets/shell.py | 5 +++-- 5 files changed, 32 insertions(+), 11 deletions(-) diff --git a/external-deps/spyder-kernels/spyder_kernels/console/kernel.py b/external-deps/spyder-kernels/spyder_kernels/console/kernel.py index 7d4ac1075cb..4b2661faa27 100644 --- a/external-deps/spyder-kernels/spyder_kernels/console/kernel.py +++ b/external-deps/spyder-kernels/spyder_kernels/console/kernel.py @@ -992,11 +992,12 @@ def set_sympy_forecolor(self, background_color='dark'): def _autoreload_magic(self, enable): """Load %autoreload magic.""" try: - value = "2" - if not enable: - value = "0" - self.shell.run_line_magic('reload_ext', 'autoreload') - self.shell.run_line_magic('autoreload', value) + if enable: + self.shell.run_line_magic('reload_ext', 'autoreload') + self.shell.run_line_magic('autoreload', "2") + else: + self.shell.run_line_magic('autoreload', "off") + except Exception: pass diff --git a/external-deps/spyder-kernels/spyder_kernels/console/start.py b/external-deps/spyder-kernels/spyder_kernels/console/start.py index f7a232602fd..eb910305957 100644 --- a/external-deps/spyder-kernels/spyder_kernels/console/start.py +++ b/external-deps/spyder-kernels/spyder_kernels/console/start.py @@ -116,9 +116,7 @@ def kernel_config(): } if is_module_installed('matplotlib'): - spy_cfg.IPKernelApp.exec_lines.append( - "get_ipython().kernel._set_mpl_backend('inline')" - ) + spy_cfg.IPKernelApp.matplotlib = "inline" # Autocall autocall_o = os.environ.get('SPY_AUTOCALL_O') diff --git a/spyder/config/main.py b/spyder/config/main.py index a87a5e50627..3f4ac827741 100644 --- a/spyder/config/main.py +++ b/spyder/config/main.py @@ -155,6 +155,7 @@ 'greedy_completer': False, 'jedi_completer': False, 'autocall': 0, + 'autoreload': False, 'symbolic_math': False, 'in_prompt': '', 'out_prompt': '', diff --git a/spyder/plugins/ipythonconsole/confpage.py b/spyder/plugins/ipythonconsole/confpage.py index f2c070089a7..b2de59f107e 100644 --- a/spyder/plugins/ipythonconsole/confpage.py +++ b/spyder/plugins/ipythonconsole/confpage.py @@ -299,6 +299,26 @@ def setup_page(self): autocall_layout.addWidget(autocall_label) autocall_layout.addWidget(autocall_box) autocall_group.setLayout(autocall_layout) + + # Autoreload group + autoreload_group = QGroupBox(_("Autoreload")) + autoreload_label = QLabel(_( + "Autoreload reloads modules automatically every time before " + "executing the Python code typed.
" + "This is a different mechanism than the UMR.
" + "It can be slow on windows because of the NTFS file system." + )) + autoreload_label.setWordWrap(True) + + autoreload_box = newcb(_("Use autoreload"), "autoreload", + tip=_("This option enables the autoreload kernel " + "extension.
Please refer to its documentation " + "to learn how to use it.")) + + autoreload_layout = QVBoxLayout() + autoreload_layout.addWidget(autoreload_label) + autoreload_layout.addWidget(autoreload_box) + autoreload_group.setLayout(autoreload_layout) # Sympy group sympy_group = QGroupBox(_("Symbolic mathematics")) @@ -369,7 +389,7 @@ def setup_page(self): self.tabs.addTab(self.create_tab( run_lines_group, run_file_group), _("Startup")) self.tabs.addTab(self.create_tab( - jedi_group, greedy_group, autocall_group, + jedi_group, greedy_group, autocall_group, autoreload_group, sympy_group, prompts_group, windows_group), _("Advanced settings")) diff --git a/spyder/plugins/ipythonconsole/widgets/shell.py b/spyder/plugins/ipythonconsole/widgets/shell.py index 33ce7e314f7..b7ed8b25993 100644 --- a/spyder/plugins/ipythonconsole/widgets/shell.py +++ b/spyder/plugins/ipythonconsole/widgets/shell.py @@ -414,8 +414,9 @@ def send_spyder_kernel_configuration(self): # Does not work if the external kernel is on windows self.set_kernel_configuration("wurlitzer", True) - # Enable autoreload_magic - self.set_kernel_configuration("autoreload_magic", True) + if self.get_conf('autoreload'): + # Enable autoreload_magic + self.set_kernel_configuration("autoreload_magic", True) self.call_kernel( interrupt=self.is_debugging(),