Repository navigation
fix(python): respect UV_PROJECT_ENVIRONMENT for uv venvs - #11475
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Central YAML (base), Organization UI (inherited) Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (6)
🚧 Files skipped from review as they are similar to previous changes (6)
📝 WalkthroughWalkthroughuv virtual environment selection now honors ChangesConfigurable uv environment selection
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant ProjectConfig
participant uv
participant VirtualEnvironment
participant EnvCache
ProjectConfig->>uv: provide UV_PROJECT_ENVIRONMENT
uv->>uv: resolve selected venv path
uv->>VirtualEnvironment: load or create selected environment
uv->>EnvCache: use selected path for cache inputs
EnvCache-->>ProjectConfig: return cached environment state
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Greptile SummaryUpdates uv virtual-environment handling to:
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Important Files Changed
Reviews (3): Last reviewed commit: "fix(python): respect UV_PROJECT_ENVIRONM..." | Re-trigger Greptile |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/toolset/toolset_env.rs`:
- Around line 286-294: Ensure the environment configuration is initialized
before deriving the cache key used by both cache lookup and save, so
UV_PROJECT_ENVIRONMENT from the [env] configuration resolves identically in
env_results_cached() and final_env(). Update the relevant initialization flow
around uv_venv_inputs and add a regression test covering a config-defined custom
uv environment and a cache hit.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Central YAML (base), Organization UI (inherited)
Review profile: CHILL
Plan: Pro Plus
Run ID: 64a94119-b4eb-42a4-95e5-2ff5b445871b
📒 Files selected for processing (5)
docs/lang/python.mde2e/core/test_python_uv_venve2e/env/test_env_cache_venvsrc/toolset/toolset_env.rssrc/uv.rs
Summary
UV_PROJECT_ENVIRONMENTwhenpython.uv_venv_autoselects, creates, and activates a uv virtual environment.venvas the empty or unset fallbackRoot cause
The uv auto-venv path was hardcoded to
<uv-root>/.venvin both activation and env cache invalidation. As a result, mise ignored the environment path selected by uv and could activate or cache the wrong virtual environment. Cache lookup also did not guarantee that config environment values were initialized before deriving the key, so alternate config construction paths could derive different lookup and save keys.Testing
mise exec -- cargo test uv::tests::test_resolve_uv_venv_pathmise run test:e2e e2e/core/test_python_uv_venv e2e/env/test_env_cache_venvmise exec -- cargo check --all-featuresmise exec -- cargo fmt --all -- --checkmise exec -- shellcheck -x e2e/core/test_python_uv_venv e2e/env/test_env_cache_venvmise exec -- shfmt -d -s e2e/core/test_python_uv_venv e2e/env/test_env_cache_venvmise exec -- markdownlint docs/lang/python.mdmise x prettier -- prettier --check docs/lang/python.mdmise run lintcould not start because hk does not recognize the Sapling working copy as a Git repository; all checks applicable to the changed files were run individually above.Addresses #7142
AI-assisted — Tool: Codex; model: OpenAI/GPT-5; version: unavailable.
Summary by CodeRabbit
New Features
UV_PROJECT_ENVIRONMENT, including relative and absolute locations.Bug Fixes
Documentation
UV_PROJECT_ENVIRONMENTguidance and examples.Tests
UV_PROJECT_ENVIRONMENTinteractions and caching.