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

Check for ipykernel in New Project Wizard #2847

Merged
merged 16 commits into from
Apr 23, 2024

Conversation

sharon-wang
Copy link
Member

@sharon-wang sharon-wang commented Apr 22, 2024

Intent

image
proj_wiz_check_for_ipykernel.mp4

Approach

  • Add new command python.isIpykernelInstalled to the python extension
  • Use the new command to check if the selected python interpreter has ipykernel installed
  • Always show a note that ipykernel will be installed when a new environment is being created
  • If an existing interpreter is being used, show a note that ipykernel will be installed if the selected interpreter doesn't have ipykernel is installed
  • Fix an issue with the disabled Next button not maintaining disabled styling

QA Notes

Does not include installing ipykernel during project creation. This will be added in a future PR.

also use the ipykernel check in the python environment substep description/feedback
This command checks if the interpreter corresponding to the provided Python path has a compatible ipykernel installed.
Instead of a function that returns either an element or string, pass the element or string directly for the PositronWizardSubStepProps description and feedback properties.
@sharon-wang sharon-wang requested review from seeM and timtmok April 22, 2024 19:40
@timtmok
Copy link
Contributor

timtmok commented Apr 22, 2024

I don't know if I've got a broken Python environment but the one that I currently use for testing receives the message that ipykernel will be installed. Oddly, an existing Homebrew install (same Python version) does not show the message.

Screen.Recording.2024-04-22.at.5.16.28.PM.mov

Copy link
Contributor

@seeM seeM left a comment

Choose a reason for hiding this comment

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

Python extension changes LGTM!

Use the pythonPath from the extraRuntimeData if it exists, otherwise use the runtimePath.
In particular, the pythonPath is needed to check if ipykernel is installed for Pyenv
environments (the runtimePath results in an error, although the pythonPath works fine,
seemingly because the runtimePath is aliased, i.e. starts with `~`). In many cases, the
pythonPath and runtimePath are the same. When they differ, it seems that the pythonPath
is the non-aliased path to the python interpreter.
@sharon-wang
Copy link
Member Author

I don't know if I've got a broken Python environment but the one that I currently use for testing receives the message that ipykernel will be installed. Oddly, an existing Homebrew install (same Python version) does not show the message.

Screen.Recording.2024-04-22.at.5.16.28.PM.mov

Ah thanks for catching this! I wasn't using Pyenv previously, but I was able to reproduce this issue after setting Pyenv up and using Positron's modal prompt to install ipykernel, then selecting my Pyenv Python interpreter in the wizard.

The issue seems to be that the runtimePath for Pyenv interpreters is aliased (starts with ~/), and something goes wrong in the ipykernel check child process when using the aliased path. The issue also occurs for some of my Conda and Venv environments which also have aliased runtime paths.

Using the extraRuntimeData.pythonPath seems like the way to go (looks to be the same path as runtimePath, but it's an absolute path instead of the ~ home directory alias). I've pushed some commits which include making this change.

Do you mind checking again to see if the issue is still happening for you?

Copy link
Contributor

@timtmok timtmok left a comment

Choose a reason for hiding this comment

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

It worked for me! I did have to eventually restart VS Code before launching a dev Positron. It seemed to not picked up any new environments that I created with pyenv cli until I did that.

@sharon-wang
Copy link
Member Author

It worked for me! I did have to eventually restart VS Code before launching a dev Positron. It seemed to not picked up any new environments that I created with pyenv cli until I did that.

Awesome! For the new environments created not getting picked, I'll have to look into whether that's because the registered runtimes in the runtime service only gets updated during startup (which will require a reload of the IDE) or maybe I need to add another listener for registered runtimes. Alternatively, I could add a "refresh" button so the user can manually refresh the interpreter dropdown list.

@sharon-wang sharon-wang merged commit 2062523 into main Apr 23, 2024
24 checks passed
@sharon-wang sharon-wang deleted the feature/project-wizard-ipykernel-check branch April 23, 2024 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants