From 6688a6d60cdd819b62930e7dcc1e8772752c3dd6 Mon Sep 17 00:00:00 2001 From: "Lumberbot (aka Jack)" <39504233+meeseeksmachine@users.noreply.github.com> Date: Wed, 9 Oct 2024 16:18:45 -0700 Subject: [PATCH] Backport PR #22631 on branch 6.x (PR: Do not check for updates if Spyder is in a system or managed environment) (#22657) --- spyder/plugins/updatemanager/widgets/update.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/spyder/plugins/updatemanager/widgets/update.py b/spyder/plugins/updatemanager/widgets/update.py index c55265e9bb1..ffaca78de69 100644 --- a/spyder/plugins/updatemanager/widgets/update.py +++ b/spyder/plugins/updatemanager/widgets/update.py @@ -14,6 +14,7 @@ import shutil import subprocess import sys +from sysconfig import get_path # Third-party imports from packaging.version import parse @@ -48,6 +49,14 @@ HEADER = _("

Spyder {} is available!


") URL_I = 'https://docs.spyder-ide.org/current/installation.html' +SKIP_CHECK_UPDATE = ( + sys.executable.startswith(('/usr/bin/', '/usr/local/bin/')) + or ( + not is_anaconda() + and osp.exists(osp.join(get_path('stdlib'), 'EXTERNALLY-MANAGED')) + ) +) + class UpdateManagerWidget(QWidget, SpyderConfigurationAccessor): """Check for updates widget.""" @@ -160,12 +169,21 @@ def start_check_update(self, startup=False): """ Check for Spyder updates using a QThread. + Do not check for updates if the environment is a system or a managed + environment. + Update actions are disabled in the menubar and statusbar while checking for updates. If startup is True, then checking for updates is delayed 1 min; actions are disabled during this time as well. """ + if SKIP_CHECK_UPDATE: + logger.debug( + "Skip check for updates: system or managed environment." + ) + return + logger.debug(f"Checking for updates. startup = {startup}.") # Disable check_update_action while the thread is working