CodeVetter · Repo Unpack · Extension points
pypa/hatch
The principal extension mechanism is pluggy registration of named classes. Hatch adds environment, collector, publisher, template, and locker registries to Hatchling's build and version registries. Builders expose artifact-version functions and ordered hooks, while environments and lockers expose lifecycle contracts. CLI command lists and dependency-source parser tables provide additional explicit dispatch points.
- Plugins declare registration hooks with hatchling.plugin.hookimpl, return one or more classes carrying PLUGIN_NAME, and advertise their hook module through project.entry-points.hatch.
- Hatch's PluginManager extends Hatchling's manager and registers environment, environment_collector, publisher, template, and locker hook providers; backend registries cover builders, build hooks, metadata hooks, version sources, and schemes.
- New environment types enter through project.config type selection and plugin_manager.environment.get; their contract includes command execution, dependency hashing, filesystem contexts, compatibility checks, and typed override options.
- LockerInterface defines supports/generate/in_sync/apply_lock plus optional installation conformance checks; resolution prefers environment locker, then project locker, then uv/pip based on the environment, and built-in hooks register both implementations.
- BuilderInterface.get_version_api maps version names to artifact-producing functions, get_config_class supplies target configuration, and hooks receive shared build_data through initialize/finalize; WheelBuilder maps standard and editable variants.
- Metadata hooks update core_raw_metadata and contribute known classifiers; dynamically introduced fields must appear in project.dynamic, while custom script loaders select a get_<plugin_id> factory or a unique interface subclass.
- Publisher selection instantiates a registered class with application, root, cache, project configuration, and user configuration; templates are ordered by PRIORITY and expose initialize_config/get_files/finalize_files stages.
- CLI additions attach to explicit Click add_command lists or argparse registration calls; dependency-source parsing uses _SOURCE_PARSERS after enforcing exactly one recognized source-type key.