Add VenvUv support and alwaysUseUv setting to control UV usage for virtual environments#940
Merged
eleanorjboyd merged 28 commits intomainfrom Nov 3, 2025
Merged
Conversation
Copilot
AI
changed the title
[WIP] Add setting to toggle using uv for venvs and support new uv tag
Add VenvUv support and alwaysUseUv setting to control UV usage for virtual environments
Oct 14, 2025
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
Contributor
There was a problem hiding this comment.
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.
karthiknadig
previously requested changes
Oct 20, 2025
Member
|
update to just search for |
aeschli
approved these changes
Nov 3, 2025
This was referenced Dec 2, 2025
eleanorjboyd
pushed a commit
that referenced
this pull request
Dec 4, 2025
# Summary microsoft/python-environment-tools#263 added two kinds of environments that can be managed by uv. #940 added `VenvUv`, and this PR adds `UvWorkspace`. Fixes #1017. # Test plan built and ran the extension on https://github.com/zsol/vscode-pyenv-repro, and after opening a python file, it picked up the correct venv automatically.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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