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: Improve implementation and UI of console envs menu (IPython console/Main interpreter) #22200

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

ccordoba12
Copy link
Member

@ccordoba12 ccordoba12 commented Jun 23, 2024

Description of Changes

  • The IPython console and Main interpreter plugins have repeated functionality to keep track of conda/pyenv envs in the system. This PR consolidates that in Main interpreter, which now emits a signal that the IPython console connects to to display info related to those envs.
  • To do that it was necessary to move almost all functionality of the Main interpreter status bar widget to its container. That will also allow us to unify that widget with the Completions one in a follow-up PR.
  • Show custom envs (i.e. those manually added by users in Preferences) in the console envs menu. That's important for people that don't use conda/pyenv for env management.
  • Break console envs menu into several sections:
    • Default, which shows the default and internal (i.e. same as Spyder) envs. In case they are the same, the internal env is not shown.
    • Conda envs
    • Pyenv envs.
    • Custom envs.
  • Except for the first section, the others are added if there are two or more envs per category. I decided to do that to not add many sections with a single env, which makes sections sort of meaningless in menus.

Visual changes

IPython console envs menu

Before After
imagen imagen

Issue(s) Resolved

Fixes #

Affirmation

By submitting this Pull Request or typing my (user)name below,
I affirm the Developer Certificate of Origin
with respect to all commits and content included in this PR,
and understand I am releasing the same under Spyder's MIT (Expat) license.

I certify the above statement is true and correct: @ccordoba12

- Capitalize names so they look better in menus.
- Add env dir to custom env names to be able to track multiple of them.
- Add for translation env names that can be translated.
- That allows to show them in the console envs menu.
- For now this only works after Spyder is restarted. But in-place
tracking (i.e. as soon as the env is added in Preferences) will be added
next.
Add in-place tracking of custom envs (i.e. as soon as they are added in
Preferences).
- Add sections for default, conda, pyenv and custom envs.
- Also, in Main Interpreter confpage change the env's name in which
Spyder is installed to Internal. That makes it easier to distinguish
between default and internal envs.
- That method is only used in its main widget.
- Also, move the update_envs method to a better place.
The test was failing because we now require that the new interpreter set
in Preferences be really different from the current one to report that
it changed.
@ccordoba12
Copy link
Member Author

@dalthviz, this is ready for review. Since I have to move code around in several places, I suggest that you take a look at these changes one commit at a time.

@dalthviz
Copy link
Member

Gave this a check and seems like the menu is working as expected 👍 Also, just in case, an idea that came to my mind while checking this is to use submenus instead of sections (so Consoles > New console in environment > pyenv/conda/custom). In my current setup I have a lot of conda envs but just a couple pyenv/custom envs and I have to go all the way down to get them:

menu_envs

However, the status bar is not showing anything at all or showing a different env name for completions. So, having over preferences the default interpreter selected, I see on Spyder start an empty completions status bar:

image

If I start changing the interpreter preference between a custom interpreter and the default one, I end up with completions refering with a different interpreter than the default one even when I have set the preferences to just use the default one again:

image

The tooltip though is showing the correct path to the selected interpreter:

image

Also, I'm not totally sure to follow the reason to move the main interpreter container to be inside the widgets module, maybe the container is now also a widget? From what I see seems like it still is a PluginMainContainer 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants