Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Do not check for updates if Spyder is in a system or managed environment #22631

Merged
merged 3 commits into from
Oct 9, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions spyder/plugins/updatemanager/widgets/update.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import shutil
import subprocess
import sys
from sysconfig import get_path

# Third-party imports
from packaging.version import parse
Expand Down Expand Up @@ -48,6 +49,14 @@
HEADER = _("<h3>Spyder {} is available!</h3><br>")
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()
Copy link
Member

@ccordoba12 ccordoba12 Oct 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we use is_conda_env here? You can import it from Spyder-kernels.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good question.

We use is_anaconda throughout Spyder's source code and it does essentially the same thing, so it does duplicate code, which is not ideal. I would suggest that we use is_conda_env from spyder-kernels exclusively and remove is_anaconda from the Spyder source code. Is there a compelling reason to keep is_anaconda?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear, I recommend removing is_anaconda in a separate PR

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest that we use is_conda_env from spyder-kernels exclusively and remove is_anaconda from the Spyder source code. Is there a compelling reason to keep is_anaconda?

is_anaconda came first and it's a simpler check because it doesn't depend on an interpreter. But I agree, we could remove it and leave is_conda_env instead, to make things simpler.

To be clear, I recommend removing is_anaconda in a separate PR

Ok, I think that's a good idea.


On a second thought, I think this is the right check in this case because we need to run it only for Spyder's interpreter. So, sorry for the noise.

and osp.exists(osp.join(get_path('stdlib'), 'EXTERNALLY-MANAGED'))
)
)


class UpdateManagerWidget(QWidget, SpyderConfigurationAccessor):
"""Check for updates widget."""
Expand Down Expand Up @@ -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
Expand Down
Loading