Discover and resolve .venv files (PEP 832)#431
Closed
edvilme wants to merge 6 commits intomicrosoft:mainfrom
Closed
Discover and resolve .venv files (PEP 832)#431edvilme wants to merge 6 commits intomicrosoft:mainfrom
edvilme wants to merge 6 commits intomicrosoft:mainfrom
Conversation
97e85bf to
2a96166
Compare
- find.rs: resolve_dot_venv returns Option<PathBuf>, use if-let to conditionally insert into search paths vec - environment_locations.rs: fix bug where ? operator on None would short-circuit the function, losing already-collected environments - path.rs: remove trailing whitespace in doc comments (fmt check) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…uation Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Collaborator
Author
|
Replaced by #433 |
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.
This pull request introduces a new utility function for resolving Python virtual environments in a project directory, supporting both the traditional
.venvdirectory and the PEP 832 convention where.venvis a file pointing to the environment. The function is thoroughly tested and integrated into multiple places in the codebase, replacing previous direct.venvpath usage to improve compatibility and correctness.New
.venvresolution utility:resolve_dot_venvtocrates/pet-fs/src/path.rs, which resolves.venvas either a directory or a file (per PEP 832), handling absolute and relative paths and validating existence.resolve_dot_venvcovering all edge cases, including missing.venv, directory, file with absolute/relative paths, non-existent targets, whitespace handling, and file-vs-directory distinction.Integration into environment discovery:
crates/pet-poetry/src/environment_locations.rsto useresolve_dot_env(likely a wrapper or alias forresolve_dot_venv) instead of directly joining.venv, ensuring correct environment resolution in Poetry projects.crates/pet-uv/src/lib.rsto useresolve_dot_envfor both workspace root and directory environment detection, ensuring.venvfile conventions are supported. [1] [2]crates/pet/src/find.rsto useresolve_dot_envwhen searching for environments in workspace folders, improving detection accuracy.