Skip to content

Environments

Pyra uses centralized environments instead of per-project .venv directories. This is a foundational design decision, not an implementation convenience.

Pyra stores environments outside the project tree so that:

  • Project checkouts stay clean — no .venv to gitignore, no stale environments after branch switches
  • Environment ownership is explicit — Pyra manages the environment lifecycle, not the user
  • Stable identity — the same project always maps to the same environment location
  • Future-proof — runtime and execution features can depend on a consistent environment contract

The environment is Pyra-managed state, not an incidental local folder.

Each environment is keyed by a stable project identity derived from the canonical project root path.

  • The same project reached through different path spellings maps to one identity
  • The environment location is stable for that canonical root
  • Metadata can reference the project by identity rather than by working directory

Pyra records metadata for each environment:

  • Project identity
  • Project root path
  • Pinned Python selector
  • Concrete interpreter version
  • Interpreter path
  • Environment path
  • Creation and update timestamps

This metadata is the contract between project discovery, sync, and execution.

CommandEffect
pyra initCreates the centralized environment
pyra useRepins the interpreter and refreshes the environment
pyra syncEnsures the environment exists, then reconciles package state

Sync prefers reusing the existing environment path and reconciling install state. It does not silently replace the environment on every run.

Sync is exact by default:

  • Install missing locked packages
  • Replace changed locked packages
  • Remove packages not present in the selected lock subset

The environment contains precisely what the lock specifies — nothing more, nothing less.

The current project is treated separately from third-party packages:

  • If [build-system] exists in pyproject.toml, install the project editable after dependency sync
  • If no build system exists, skip project installation cleanly

This keeps the environment useful for both distributable packages and runnable projects.

Traditional .venv directories in the project root have several problems:

  • They bloat the project tree
  • They create confusion when multiple tools (pip, poetry, pipenv) compete over .venv
  • They couple environment state to the checkout, creating stale state after branch switches
  • They make environment identity implicit

Pyra’s centralized model makes the environment a first-class managed resource with explicit identity, owned lifecycle, and deterministic state.

Environments are stored under Pyra’s data directory:

  • macOS: ~/Library/Application Support/pyra/environments/
  • Linux: ~/.local/share/pyra/environments/

Each environment is keyed by the canonical project identity.