Repository navigation
Description
Problem
PET currently classifies Hatch-managed virtual environments as Venv because they contain a pyvenv.cfg file. This causes downstream consumers (e.g., vscode-python-environments) to incorrectly categorize Hatch environments as plain venvs, leading to bugs like environments leaking into the wrong manager collection.
See: microsoft/vscode-python-environments#1507 (Layer 2 discussion), and related issues microsoft/vscode-python-environments#1471, microsoft/vscode-python-environments#1485, microsoft/vscode-python-environments#1491.
Proposed Solution
Follow the established pattern used by Poetry, Pipenv, Uv, and VirtualEnvWrapper:
- Add
Hatchvariant toPythonEnvironmentKindincrates/pet-core/src/python_environment.rs - Create a
pet-hatchcrate with aHatchlocator that implements theLocatortrait - Insert into locator chain in
crates/pet/src/locators.rsbeforeVenv(so it claims hatch envs before the generic venv locator does)
Hatch Environment Identification
Hatch environments can be identified by their storage locations and structure:
- Default virtual storage (
~/.local/share/hatch/env/virtual/on Unix, platform-specific on Windows) — environments named{project-hash}/{env-name} - Project-local (
{project}/.hatch/directory when configured withpath = ".hatch"inhatch.toml) pyvenv.cfgmetadata — Hatch sets thepromptfield to{env-name}- Hatch config files — presence of
hatch.tomlor[tool.hatch]inpyproject.tomlin the project can confirm association
The locator should:
- Discover environments in known hatch directories (from hatch config or default data dir)
- In
try_from(), identify an env as Hatch if its path is inside a known hatch env directory - Set the
project_pathfield to link the environment back to the originating project
Additional Context
This is similar to how pet-poetry and pet-uv identify their environments — they use known directory structures and config files to claim ownership before the generic Venv locator runs.
Activity
flying-sheep commentedon May 7, 2026
Hi, as said, I don’t think that’s the right approach:
feat: add pet-hatch locator for Hatch environments (Fixes #450) (#460)