Skip to content

Commit db89b6e

Browse files
committed
feat: add pet-hatch locator for Hatch environments (Fixes #450)
Adds a new pet-hatch crate that detects Hatch-managed virtual environments so they are no longer misclassified as plain Venv by downstream consumers. Implementation matches Hatch's actual storage layout from src/hatch/env/virtual.py: - Default storage: <data_dir>/env/virtual/<project_name>/<project_id>/<venv_name> (3 levels deep) - HATCH_DATA_DIR env var honoured; never silently falls back to platform default when set \ example from the issue) - Locator inserted before Venv so Hatch claims its envs first - 15 unit tests covering layout depth (rejects 2 / 4 levels), HATCH_DATA_DIR semantics, project-local config, and platform defaults
1 parent 93285a8 commit db89b6e

8 files changed

Lines changed: 911 additions & 0 deletions

File tree

Cargo.lock

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/pet-core/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ pub struct Configuration {
4343
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
4444
pub enum LocatorKind {
4545
Conda,
46+
Hatch,
4647
Homebrew,
4748
LinuxGlobal,
4849
MacCommandLineTools,

crates/pet-core/src/python_environment.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub enum PythonEnvironmentKind {
1919
PyenvVirtualEnv, // Pyenv virtualenvs.
2020
Pipenv,
2121
Poetry,
22+
Hatch,
2223
MacPythonOrg,
2324
MacCommandLineTools,
2425
LinuxGlobal,

crates/pet-hatch/Cargo.toml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[package]
2+
name = "pet-hatch"
3+
version.workspace = true
4+
edition.workspace = true
5+
license.workspace = true
6+
7+
[dependencies]
8+
pet-core = { path = "../pet-core" }
9+
pet-fs = { path = "../pet-fs" }
10+
pet-python-utils = { path = "../pet-python-utils" }
11+
serde = { version = "1.0.226", features = ["derive"] }
12+
toml = "0.9.7"
13+
log = "0.4.21"
14+
15+
[dev-dependencies]
16+
tempfile = "3.13"

0 commit comments

Comments
 (0)