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

Fix behavior when missing Pip #6020

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open

Conversation

samclark2015
Copy link

@samclark2015 samclark2015 commented Jan 16, 2025

When selecting an interpreter missing ipykernel, the UI prompt now states that both Pip and ipykernel must be installed. ProductInstaller logic was modified to pass flags to enable Pip to be installed automatically. Additional flags were set in ProductInstaller to enable the Pip install to respect the python.installModulesInTerminal setting.

Screenshot 2025-01-16 at 9 43 13 AM

Addresses #5505

Release Notes

New Features

  • N/A

Bug Fixes

  • N/A

QA Notes

Updated UI prompt to include Pip in the modules to be installed when missing, and updated installer logic to actually do that.
Copy link

github-actions bot commented Jan 16, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

Copy link

github-actions bot commented Jan 16, 2025

E2E Tests 🚀
This PR will run tests tagged with: @:critical

readme  valid tags

@samclark2015
Copy link
Author

I have read the CLA Document and I hereby sign the CLA

Revised l10n call to conform better to the localization API
Mocked up environment to ensure that Pip gets installed when `ModuleInstallFlags.installPipIfRequired` is set
@samclark2015
Copy link
Author

Added a unit test to check the business logic of installing Pip; do we need an e2e test?

@samclark2015
Copy link
Author

P.S., a screencap of the new behavior:
https://github.com/user-attachments/assets/7c98e872-a40a-4480-870d-7ef9f1573727

@samclark2015 samclark2015 marked this pull request as ready for review January 16, 2025 22:03
Copy link
Contributor

@austin3dickey austin3dickey left a comment

Choose a reason for hiding this comment

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

nice, I tried it out and it seems to work well! (Can't tell if the test failures are related to this PR or not)

ModuleInstallFlags.installPipIfRequired,
);
expect(result).to.equal(InstallerResponse.Installed, 'Should be Installed');
});
Copy link
Contributor

Choose a reason for hiding this comment

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

nice test!

let message;
if (!hasPip) {
message = vscode.l10n.t(
'To enable Python support, Positron needs to {0} the packages <code>{1}</code> and <code>{2}</code> for the active interpreter {3} at: <code>{4}</code>.',
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you change the header of the popup too? Right now it says Install Python package "ipykernel"? even if the body asks to install pip too.

Copy link
Author

Choose a reason for hiding this comment

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

Ah - good catch! I'll check out implementing this too. 😄

Copy link
Author

Choose a reason for hiding this comment

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

Does this verbiage sound good?

Screenshot 2025-01-17 at 11 29 30 AM

Copy link
Contributor

Choose a reason for hiding this comment

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

Is pip a Python package itself? 🤔

Copy link
Author

Choose a reason for hiding this comment

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

Yes! A package which exposes a console script.

In this case, it is being installed by the ensurepip builtin module.

Also removes an unnecessary Positron overlay comment
Copy link
Contributor

@juliasilge juliasilge left a comment

Choose a reason for hiding this comment

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

This is looking great and working well for me!

With no pip or ipykernel (note that we should update the header as pointed out by @austin3dickey):

Screenshot 2025-01-17 at 10 24 23 AM

With no ipykernel only:

Screenshot 2025-01-17 at 10 26 04 AM

We mostly, sort of support uv right now and certainly want to do better for uv users as we move forward; what happens if someone is using uv? In term of us detecting if pip is there or not? See https://docs.astral.sh/uv/pip/compatibility/

And then same question for conda, which do expect to work in Positron well. I believe that currently for conda environments, the call to this.install() uses conda not pip.

Copy link
Contributor

@isabelizimm isabelizimm left a comment

Choose a reason for hiding this comment

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

it doesn't look like the tests failures are related to these changes since it looks like they're failing in setup (?). it might be worth trying to kick them off again. nice tests and the change looks reasonable to me!

@juliasilge
Copy link
Contributor

The CI failures definitely look unrelated, and sadly we are having some MASSIVE CI PROBLEMS right now as runners moved to Ubuntu 24. Let's not merge this until we get an all clear from QA folks on the situation on main.

@austin3dickey
Copy link
Contributor

what happens if someone is using uv?

FWIW I set up my local test by doing uv venv in the positron-python directory and picking the venv that was created there, since I think uv venvs don't come with pip by default.

@samclark2015
Copy link
Author

UV behavior: As Austin said, no Pip, but it gets installed per the new behavior. Is this what we want (vs. ipykernel getting installed directly by uv)?

Conda behavior: I created a conda environment with just Python (+ required dependencies). I got no prompt to install ipykernel when activating it in Positron. No ipykernel in the conda list output. Do we know if Conda has some integrated version of ipykernel?

@juliasilge
Copy link
Contributor

UV behavior: As Austin said, no Pip, but it gets installed per the new behavior. Is this what we want (vs. ipykernel getting installed directly by uv)?

I do not think we should install pip into uv environments, no. I don't know if we can install ipykernel into uv easily right now (does it exist as one of the installer types already?) but solving that is probably out of scope for this PR. Let's think about this PR as installing pip when needed for non-conda, non-uv environments.

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.

4 participants