-
Notifications
You must be signed in to change notification settings - Fork 34
Add support for detecting UV-created virtual environments as venv-uv type
#260
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
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>
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
|
@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>
Implemented as requested! I've removed the separate Changes made in commit d33381b:
|
|
@copilot looks like you have clippy errors. please fix. |
Co-authored-by: karthiknadig <3840081+karthiknadig@users.noreply.github.com>
✅ 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.