Add support for detecting UV-created virtual environments as venv-uv type#260
Closed
Add support for detecting UV-created virtual environments as venv-uv type#260
venv-uv type#260Conversation
Co-authored-by: karthiknadig <3840081+karthiknadig@users.noreply.github.com>
Co-authored-by: karthiknadig <3840081+karthiknadig@users.noreply.github.com>
Co-authored-by: karthiknadig <3840081+karthiknadig@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add a new environment type
Add support for detecting UV-created virtual environments as Sep 18, 2025
venv-uv for environments created with uv.
details:
You can check if a ´.venv´ has been created with UV by reading its pyvenv.cfg file, if it is an UV one there will be an "uv" entry.
With UV: pyvenv.cfg ***No...venv-uv type
Member
|
@copilot Don't create a new crate. Since the detection for the venv already exists, use that. Just add support for a new kind when venv is created using uv. |
…ad of creating new crate Co-authored-by: karthiknadig <3840081+karthiknadig@users.noreply.github.com>
Contributor
Author
Implemented as requested! I've removed the separate Changes made in commit d33381b:
|
Member
|
@copilot looks like you have clippy errors. please fix. |
Co-authored-by: karthiknadig <3840081+karthiknadig@users.noreply.github.com>
Contributor
Author
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.
✅ Implementation Complete: Add new environment type
venv-uvfor environments created withuvSummary
Successfully implemented a new
venv-uvenvironment type that can distinguish UV-created virtual environments from regular venv environments by detecting the presence of auv = <version>entry in thepyvenv.cfgfile.⚡ UPDATED APPROACH (Based on feedback from @karthiknadig)
Instead of creating a separate
pet-venv-uvcrate, the implementation now extends the existingpet-venvcrate to handle UV detection while maintaining the same Venv locator.Key Features Implemented
1. UV Detection Logic
PyVenvCfgstruct withuv_versionfield andis_uv()methodparse_uv_version()function to parseuv = <version>lines from pyvenv.cfguv = 0.8.14,uv = "0.8.14",uv = '0.8.14'2. Enhanced Venv Locator
Venvlocator to support bothPythonEnvironmentKind::VenvandPythonEnvironmentKind::VenvUvtry_from()method to return appropriate environment kindis_venv_uv(),is_venv_uv_dir()for external use3. Unified Architecture
Venvlocator handles both regular and UV-created virtual environmentsTesting & Quality
8 Comprehensive Tests Added:
test_parse_uv_version()- Validates UV version parsing from various formatstest_pyvenv_cfg_detects_uv()- Tests PyVenvCfg UV detection capabilitytest_pyvenv_cfg_regular_venv()- Ensures regular venvs are not misidentifiedtest_is_venv_uv_dir_detects_uv_environment()- Directory-level UV detectiontest_is_venv_uv_dir_does_not_detect_regular_environment()- Rejects regular venvstest_is_venv_uv_dir_handles_nonexistent_environment()- Graceful error handlingtest_venv_locator_detects_uv_kind()- Tests locator returns VenvUv for UV environmentstest_venv_locator_detects_regular_venv_kind()- Tests locator returns Venv for regular environmentsQuality Assurance:
Example Usage
UV Environment
pyvenv.cfg:→ Detected as:
PythonEnvironmentKind::VenvUvRegular Venv
pyvenv.cfg:→ Detected as:
PythonEnvironmentKind::VenvArchitecture Benefits
The implementation is complete, thoroughly tested, and follows the project's architectural guidelines.
Created from VS Code via the GitHub Pull Request extension.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.