pyssg is pre-1.0 and under active development - APIs, config, and themes may change.
pyssg.deploy

1 min read

pyssg.deploy

Deploy targets: registry and public surface.

Deploy is a periphery subsystem; the engine never imports it. A target is a small object that knows how to push a built site to one hosting provider; the pipeline orchestrates the provider-agnostic part (build, hash, skip, persist).

Built-in targets are not registered automatically: each one lives in its own module (github_pages, cloudflare, netlify) and calls :func:register at import time. The CLI imports them lazily, so a user who never runs pyssg deploy does not pay for the optional third-party imports. For tests, the registry can be passed in explicitly via the targets keyword of :func:pyssg.deploy.pipeline.run_deploy, so there is no need to mutate module-level state.

register(target: DeployTarget) -> None

Add a target to the global registry.

Raises :class:DeployError if a target with the same name is already registered, which catches double-imports and accidental name clashes between built-in and third-party targets.

get_target(name: str, *, targets: dict[str, DeployTarget] | None = None) -> DeployTarget

Look up a target by name; raise :class:DeployError if unknown.

targets defaults to the global registry; tests pass an explicit dict to avoid touching module state.

list_targets(*, targets: dict[str, DeployTarget] | None = None) -> list[str]

Names of registered targets, sorted.

load_builtin_targets() -> None

Import the built-in target modules so they register themselves.

Idempotent: a module is imported at most once (Python caches it), so calling this repeatedly does not double-register. Targets whose module does not exist yet (a future milestone) are skipped silently; any other import error -- a real bug in a target module -- is allowed to propagate.

The CLI calls this before dispatching a deploy so the global :data:TARGETS registry is populated; tests that pass an explicit targets= registry do not need it and stay isolated from module-level state.