Implement UV virtual environment support in Python Environment Tools #230
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.
This PR adds support for discovering virtual environments created by UV within the Python Environment Tools (PET) codebase.
Overview
UV is a fast Python package installer and resolver that creates virtual environments in cache directories. This implementation follows the existing architecture by creating a new
pet-uv
crate that discovers UV cache directories and enumerates virtual environments, treating them as standard virtual environments without introducing new environment types.Changes Made
1. New
pet-uv
Cratecrates/pet-uv/
with UV-specific environment discovery logicUV_CACHE_DIR
environment variable%LOCALAPPDATA%
on Windows~/.cache/uv
,~/Library/Caches/uv
, etc.){cache_dir}/environments-v2/
subdirectoriesis_conda_env()
helper2. Integration with Existing Discovery
crates/pet/src/find.rs
to include UV paths in global virtual environment searchVirtualEnv
type by existing locators3. Cross-Platform Support
%LOCALAPPDATA%\uv
)~/Library/Caches/uv
)~/.cache/uv
)4. Testing
Example Usage
With UV environments in the cache directory, PET now automatically discovers them:
Architecture Benefits
VirtualEnv
typeTesting
Verified that UV environments are properly discovered and identified:
This implementation follows the established patterns in the codebase and maintains clean separation of concerns while adding robust UV virtual environment support.
Created from VS Code via the GitHub Pull Request extension.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.