FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Discover and resolve .venv files (PEP 832) by edvilme · Pull Request #431 · microsoft/python-environment-tools · GitHub

Discover and resolve .venv files (PEP 832) - #431

Closed
Eduardo Villalpando Mello (edvilme) wants to merge 6 commits into
microsoft:mainfrom
edvilme:pep832
Closed

Discover and resolve .venv files (PEP 832)#431
Eduardo Villalpando Mello (edvilme) wants to merge 6 commits into
microsoft:mainfrom
edvilme:pep832

Conversation

Copy link
Copy Markdown
Collaborator

This pull request introduces a new utility function for resolving Python virtual environments in a project directory, supporting both the traditional .venv directory and the PEP 832 convention where .venv is a file pointing to the environment. The function is thoroughly tested and integrated into multiple places in the codebase, replacing previous direct .venv path usage to improve compatibility and correctness.

New .venv resolution utility:

  • Added resolve_dot_venv to crates/pet-fs/src/path.rs, which resolves .venv as either a directory or a file (per PEP 832), handling absolute and relative paths and validating existence.
  • Comprehensive unit tests for resolve_dot_venv covering 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:

  • Updated crates/pet-poetry/src/environment_locations.rs to use resolve_dot_env (likely a wrapper or alias for resolve_dot_venv) instead of directly joining .venv, ensuring correct environment resolution in Poetry projects.
  • Updated crates/pet-uv/src/lib.rs to use resolve_dot_env for both workspace root and directory environment detection, ensuring .venv file conventions are supported. [1] [2]
  • Updated crates/pet/src/find.rs to use resolve_dot_env when searching for environments in workspace folders, improving detection accuracy.

- 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>
Eduardo Villalpando Mello (edvilme) changed the title Pep832 Discover and resolve .venv files (PEP 832) Apr 16, 2026

Copy link
Copy Markdown
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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL