-
Notifications
You must be signed in to change notification settings - Fork 92
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
base: main
Are you sure you want to change the base?
Conversation
Updated UI prompt to include Pip in the modules to be installed when missing, and updated installer logic to actually do that.
All contributors have signed the CLA ✍️ ✅ |
E2E Tests 🚀 |
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
Added a unit test to check the business logic of installing Pip; do we need an e2e test? |
P.S., a screencap of the new behavior: |
There was a problem hiding this 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'); | ||
}); |
There was a problem hiding this comment.
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>.', |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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? 🤔
There was a problem hiding this comment.
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
There was a problem hiding this 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):
With no ipykernel only:
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.
There was a problem hiding this 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!
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 |
FWIW I set up my local test by doing |
UV behavior: As Austin said, no Pip, but it gets installed per the new behavior. Is this what we want (vs. Conda behavior: I created a conda environment with just Python (+ required dependencies). I got no prompt to install |
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. |
For conda, for learning mainly for you @samclark2015, can you step through with the debugger and see what is happening around here for conda: positron/extensions/positron-python/src/client/positron/session.ts Lines 242 to 246 in 1093ae4
i.e. is the infrastructure already there checking if the conda env has appropriate ipykernel? |
The infrastructure does check for for ipykernel in conda environments; it was being bypassed due to ipykernel being installed in my user directory ( Re UV: there is no infrastructure to install via UV, nor to even detect if it is a UV environment. Currently, it only detects Conda, Pipenv, and Poetry environments. If none of those match, it's declared a Pip environment and subsequently uses Pip to install the package. Some questions:
|
For uv, we've got a couple of other issues tracking better support: The only thing I would advocate we do in this PR is if possible not install pip into uv (because I think that will be very weird/bad), but I am open to discussion on that, especially if we don't even have tools to see if we are in an uv env yet. If so, let's open a followup issue to address this. Our uv users will be able to workaround by installing ipykernel when setting up their environments (they have to do this now anyway, i.e. #3093). |
I am going to look to @austin3dickey and @isabelizimm for answers on this. |
Doesn't look like there are tools to tell if it's UV; it's labeled as |
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 inProductInstaller
to enable the Pip install to respect thepython.installModulesInTerminal
setting.Addresses #5505
Release Notes
New Features
Bug Fixes
QA Notes