-
Notifications
You must be signed in to change notification settings - Fork 29
Add VenvUv support and alwaysUseUv setting to control UV usage for virtual environments #940
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
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
Co-authored-by: eleanorjboyd <26030610+eleanorjboyd@users.noreply.github.com>
3a25051 to
11bfc6e
Compare
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 UV-created virtual environments and introduces a configurable setting to control when UV is used for managing virtual environments. The implementation allows UV to always manage environments it creates while giving users control over whether UV manages standard venvs.
Key changes:
- Added
VenvUvenvironment kind to distinguish UV-created virtual environments - Introduced
python-envs.alwaysUseUvsetting (default: true) to control UV usage for non-UV environments - Implemented UV environment tracking system using persistent state
- Updated all virtual environment operations to respect the new setting and environment type
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
src/managers/common/nativePythonFinder.ts |
Added venvUv enum value to identify UV-created environments |
src/managers/builtin/uvEnvironments.ts |
New module implementing UV environment tracking with persistent state |
src/managers/builtin/helpers.ts |
Added shouldUseUv() function and cache reset capability for UV detection |
src/managers/builtin/venvUtils.ts |
Updated environment discovery, creation, and removal to handle UV environments |
src/managers/builtin/utils.ts |
Updated package management operations to use the new UV detection logic |
src/managers/builtin/pipManager.ts |
Reordered imports (no functional change) |
package.json |
Added alwaysUseUv setting configuration |
package.nls.json |
Added localization string for the new setting |
src/test/managers/builtin/venvUtils.uvTracking.unit.test.ts |
Comprehensive tests for UV environment tracking functions |
src/test/managers/builtin/helpers.shouldUseUv.unit.test.ts |
Tests for UV usage decision logic with various scenarios |
src/test/managers/builtin/helpers.isUvInstalled.unit.test.ts |
Tests for UV installation detection and caching |
.github/instructions/testing-workflow.instructions.md |
Added testing guidelines and learnings from this implementation |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
update to just search for |
Overview
This PR implements support for UV-created virtual environments and adds a new setting to control when UV is used for managing virtual environments, as requested in the issue.
Changes
1. New Environment Kind:
VenvUvAdded
venvUv = 'Uv'to theNativePythonEnvironmentKindenum to represent virtual environments created with UV. This tag comes from PET's native locator when it detectsuv_versionin thepyvenv.cfgfile.2. New Setting:
python-envs.alwaysUseUv{ "python-envs.alwaysUseUv": { "type": "boolean", "default": true, "scope": "machine", "description": "When set to true, uv will be used to manage all virtual environments if available. When set to false, uv will only manage virtual environments explicitly created by uv." } }3. Smart UV Detection Logic
Introduced a
shouldUseUv()helper function that determines when to use UV:alwaysUseUvsetting istrue(if installed)This ensures that UV-created environments always use UV for management, while giving users control over whether UV should manage standard venvs.
4. Updated Operations
All virtual environment and pip operations now respect the new setting:
findVirtualEnvironments()andresolveVenvPythonEnvironmentPath()now handle bothVenvandUvkindscreateWithProgress()uses the setting to decide betweenuv venvandpython -m venvrefreshPipPackagesRaw()andmanagePackages()use the setting to decide betweenuv pipandpython -m pipBehavior