CodeVetter · Repo Unpack · Behavior traces
pypa/hatch
The source supports ordered walkthroughs of startup, command execution, environment persistence, artifact builds, and publishing. Conditions such as existing environments, skip-install, backend selection, and already-uploaded artifacts materially change the sequence. Environment execution is driven by a generator that prepares and runs work after the command handler populates its context. These are source traces, not observed execution results.
- Startup: main → hatch → Application → ConfigFile.restore if the default file is missing → ConfigFile.load → style initialization → storage directory selection → explicit or current-directory Project selection.
- Normal command execution: run parses ENV:ARGS → ctx.invoke(env.run) → parse_matrix_variables/select_environments → Application.runner_context → Project.get_environment → compatibility check only if the environment does not exist.
- Missing-environment preparation: managed_environment → metadata.reset → environment.create → optional pre-install commands → normal/editable project installation → optional post-install commands; skip-install bypasses the installation block.
- Persistence after preparation: dependency_hash → EnvironmentMetadata.dependency_hash → optional generate_lockfile for locked inputs → dependencies_in_sync → optional sync_dependencies → update_dependency_hash → JSON write.
- Shell execution: execute_context applies context.env_vars → run_shell_commands enters command_context → resolve_commands/expand_command formats scripts → run_shell_command invokes the platform; parent SIGINT handling is restored in finally and exit-code policy is applied.
- Hatchling build: build → _build_project → prepare_build_environment → python -m hatchling build → build_impl selects builder → BuilderInterface.build validates metadata and initializes hooks → WheelBuilder.build_standard → finalize hooks → artifact yield.
- Alternative-backend build: prepare_build_environment gathers backend get_requires results → _build_project accepts only sdist/wheel → BuildFrontend generates and executes a hook script → output.json identifies the artifact → the frontend moves it to the requested directory.
- Publish: CLI selects and checks the publisher → IndexPublisher resolves repository and credentials → recurse_artifacts reads metadata → simple API lookup skips existing filenames → upload_artifact sends new files → successful versions print URLs → write_updated_data persists prompted authentication.