-
Notifications
You must be signed in to change notification settings - Fork 101
python: add uv to New Project Wizard #7723
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
Conversation
E2E Tests 🚀 |
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.
Pull Request Overview
This PR adds support for using uv as an option for creating Python virtual environments in the New Project Wizard and via Python commands. Key changes include updating configuration options and state management to include uv, introducing new utilities and a uv creation provider, and updating test and command registrations to support uv.
Reviewed Changes
Copilot reviewed 21 out of 21 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
test/e2e/pages/newProjectWizard.ts | Updated test options to include uv for Python environment creation. |
src/vs/workbench/services/positronNewProjectService.ts | Updated service to check for uvPythonVersion in the project configuration. |
src/vs/workbench/browser/positronNewProjectWizard/* | Added and updated utilities, state management, and components to support uv environments. |
extensions/positron-python/* | Integrated uv support in environment creation, provider registration, and command definitions. |
Comments suppressed due to low confidence (1)
src/vs/workbench/browser/positronNewProjectWizard/utilities/pythonEnvironmentStepUtils.ts:31
- [nitpick] Using '.venv' as the default directory for non-Conda providers means that uv environments will share the same folder name as venv environments. Consider using a distinct folder name (e.g., '.uv') for uv environments if that aligns with the design requirements.
const envDir = envProviderName === PythonEnvironmentProvider.Conda ? '.conda' : '.venv';
...nsions/positron-python/src/client/pythonEnvironments/creation/provider/uvCreationProvider.ts
Outdated
Show resolved
Hide resolved
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.
Tried things out a bit for a first pass-- this is looking great! Everything seems to work as I expect.
Some thoughts for you to consider: would it be possible to hide uv
as an option from the dropdown if it is not installed, rather than showing it and then giving an error? Alternatively (or maybe additionally), could uv be moved to the bottom of the list so venv can have the top spot? We know everyone who has Python will have venv, but not everyone will have uv.
I'll look through the actual code on Monday for feedback there.
yes - hiding it from the list is a great idea! Testing it locally, it feels like a much better experience than venv. I didn't even have to implement the progress-tracking functionality that venv and conda do, because it only takes a moment to generate the environment. So I think if it's installed, I'd rather keep it at the top as the recommended selection. |
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.
E2E test looks great! I will check later this week if we can turn it and the others in the file on for WEB.
type: ProjectType.PYTHON_PROJECT, | ||
title: projectTitle, | ||
status: 'new', | ||
pythonEnv: 'uv', // test relies on uv already installed on machine |
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.
do we have uv
in all our CI tests now, or will we need to add it?
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, it's in all our testing setups now 💜 thanks @testlabauto !
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.
Actually I just found out it's not on windows. So now we don't run this test on windows. This seems like a good forcing function for me to set up my new windows laptop and test this out :)
extensions/positron-python/src/client/pythonEnvironments/creation/provider/uvUtils.ts
Show resolved
Hide resolved
Right, your comment reminded me that's why I did this in the first place 😂 I still think it's strange to have the first thing that shows up not work, so it shouldn't be too hard to just reorder to venv first if uv doesn't exist. |
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 working well for me on Desktop and Server Web on Mac 👌 The .venv creation feels almost instant ⚡
One more test update! Could you please update extensions/positron-python/src/test/positron/createEnvApi.unit.test.ts
to include a couple Uv additions:
const envOptionsWithInfo = {
withInterpreterPath: { ...envOptions },
withCondaPythonVersion: { ...envOptions, interpreterPath: undefined, condaPythonVersion: '3.12' },
withUvPythonVersion: { ...envOptions, interpreterPath: undefined, uvPythonVersion: '3.13' }, // <-- add this line
};
const envOptionsMissingInfo = {
noProviderId: { ...envOptions, providerId: undefined },
noPythonSpecified: { ...envOptions, interpreterPath: undefined, condaPythonVersion: undefined, uvPythonVersion: undefined }, // <-- add `uvPythonVersion` here
};
If you'd like some Windows testing before merging, we could run the @:win
suite on this PR
Cool, I was able to implement "put uv at the bottom of the list if it's not installed" and "flesh out the unit tests some more". Thanks for the feedback! Check it out whenever you have a chance |
I just tried on Windows 11 and it looks good! I checked:
I did not try without uv 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.
lgtm with the new changes! 👾
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.
some small things, otherwise LGTM too!
extensions/positron-python/src/client/pythonEnvironments/creation/createEnvApi.ts
Outdated
Show resolved
Hide resolved
extensions/positron-python/src/client/pythonEnvironments/creation/createEnvApi.ts
Outdated
Show resolved
Hide resolved
extensions/positron-python/src/client/pythonEnvironments/creation/createEnvApi.ts
Outdated
Show resolved
Hide resolved
extensions/positron-python/src/client/pythonEnvironments/creation/createEnvApi.ts
Outdated
Show resolved
Hide resolved
…ion/provider/uvCreationProvider.ts Co-authored-by: Copilot <[email protected]> Signed-off-by: Austin Dickey <[email protected]>
Co-authored-by: sharon <[email protected]> Signed-off-by: Austin Dickey <[email protected]>
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.
LGTM!
Addresses #5165.
This PR adds support for using
uv
, if it's installed, to create venvs in:Python: Create Environment
andPython: Select Interpreter
commandsRelease Notes
New Features
uv
as an option for creating Python projects in the New Project Wizard (FR: Support uv in New Project wizard #5165)Bug Fixes
QA Notes
I added a new e2e test in this PR.
When testing this, try out a few scenarios:
uv
installed on your system; you should get an informative errorPython:
commands I mentioned above@:extensions @:new-project-wizard @:vscode-settings @:win