Commit d581272
authored
Fixes #450.
Adds a new `pet-hatch` crate so Hatch-managed virtual environments are
no longer misclassified as plain `Venv` by downstream consumers.
### Implementation
Matches Hatch's actual storage layout from
[`src/hatch/env/virtual.py`](https://github.com/pypa/hatch/blob/master/src/hatch/env/virtual.py):
- **Default storage:**
`<data_dir>/env/virtual/<project_name>/<project_id>/<venv_name>` (3
levels deep, not 2).
- **`HATCH_DATA_DIR`** is honoured and never silently falls back to the
platform default when set.
- **Project-local discovery** via `[tool.hatch.dirs.env].virtual` in
`pyproject.toml` or `[dirs.env]` in `hatch.toml`. Handles the `virtual =
".hatch"` example called out in the issue.
- Hatch locator is inserted **before `Venv`** so it claims envs first.
- `LocatorKind::Hatch` registered as
`RefreshStatePersistence::ConfiguredOnly` (workspace-driven discovery).
### Tests
15 unit tests covering:
- Default-storage layout matches at exactly 3 levels deep; rejects
2-deep and 4-deep prefixes.
- `HATCH_DATA_DIR` semantics — used when set, no fallback to platform
default.
- Project-local discovery via both `pyproject.toml` and `hatch.toml`;
rejected without `dirs.env.virtual` config.
- Per-platform `platformdirs` defaults (Linux/macOS/Windows).
### Replaces #451
This PR replaces #451, which had a fundamental layout bug: it assumed
envs are stored 2 levels deep under `<data_dir>/env/virtual`
(`<project-hash>/<env-name>`). Per Hatch's source, the actual layout is
3 levels deep (`<project_name>/<project_id>/<venv_name>`), so #451 would
fail to detect any real Hatch env in the default storage location.
1 parent 93285a8 commit d581272
8 files changed
Lines changed: 1556 additions & 0 deletions
File tree
- crates
- pet-core/src
- pet-hatch
- src
- pet
- src
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| 46 | + | |
46 | 47 | | |
47 | 48 | | |
48 | 49 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
| 22 | + | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
0 commit comments