hatch build
A minimal CLI wrapper around hatchling build
Overview
This library provides a minimal CLI hatch-build, equivalent to hatchling build except for the enablement of passthrough arguments.
hatch-build -- --my-custom-plugin-arg
As a convenience, we provide an argparse wrapper to extract the extra args:
from hatch_build import parse_extra_args
args, extras = parse_extra_args(my_argparse_parser)
Configuration
If you manage your hatch plugin config as a pydantic model, a function is provided to automatically expose fields as command line arguments.
from hatchling.builders.hooks.plugin.interface import BuildHookInterface
from pydantic import BaseModel
from hatch_build import parse_extra_args_model
class MyPluginConfig(BaseModel, validate_assignment=True):
extra_arg: bool = False
extra_arg_with_value: str = "default"
extra_arg_literal: Literal["a", "b", "c"] = "a"
class MyHatchPlugin(BuildHookInterface):
PLUGIN_NAME = "my-hatch-plugin"
def initialize(self, version: str, build_data: dict[str, Any]) -> None:
my_config_model = MyPluginConfig(**self.config)
parse_extra_args_model(my_config_model)
print(f"{my_config_model.extra_arg} {my_config_model.extra_arg_with_value} {my_config_model.extra_arg_literal}")
# > hatch-build -- --extra-arg --extra-arg-with-value "test" --extra-arg-literal b
# True test b
Metadata
Release files for hatch-build 0.5.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hatch_build-0.5.1.tar.gz | 10.4 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hatch_build-0.5.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 21.3 kB
Release files / hatch_build-0.5.1.tar.gz
| Download URL | hatch_build-0.5.1.tar.gz |
|---|---|
| Size | 10.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a6b1628d6483a5728ffc8abde4fd083cc8a2f91ccf939787df5635b7ed33f3bb
|
|
BLAKE2b-256 checksum How to use checksums |
0373463fe1c61e59aa3c34c4eb222a772a9d5baeec3eb45b51124a417e58d99e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.15
|
Release files / hatch_build-0.5.1-py3-none-any.whl
| Download URL | hatch_build-0.5.1-py3-none-any.whl |
|---|---|
| Size | 10.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5d72df4a26f49551a2b85272e092f91a844ff318bab9cee8fd678b408b168def
|
|
BLAKE2b-256 checksum How to use checksums |
e037a70af24e5c21f8cc01f2908f68ef4c2ecf81047639a44649db14eedede37
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.11.15
|