Skip to main content

A minimal CLI wrapper around hatchling build

Project description

hatch build

A minimal CLI wrapper around hatchling build

Build Status codecov License PyPI

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[MyPluginConfig]):
    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

[!NOTE] This library was generated using copier from the Base Python Project Template repository.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hatch_build-0.5.0.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hatch_build-0.5.0-py3-none-any.whl (10.9 kB view details)

Uploaded Python 3

File details

Details for the file hatch_build-0.5.0.tar.gz.

File metadata

  • Download URL: hatch_build-0.5.0.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for hatch_build-0.5.0.tar.gz
Algorithm Hash digest
SHA256 63eae1f4455764e91198db31f4e2e9d3936a8998a8bf8934e4658053b397af6c
MD5 985b3c3e5765bbc58a14416a2ca6bf93
BLAKE2b-256 65c1ee693788241b47d4ce4a6a35eac465ac027efa08fab524c0fd69ed712270

See more details on using hashes here.

File details

Details for the file hatch_build-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: hatch_build-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 10.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for hatch_build-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f1ca94c6c8d9ae0be4d43bb74f2b54164c9287d777c87634956a067290430064
MD5 9294b875d29f24866746c7f58a2e934f
BLAKE2b-256 1be0471ea1ea244cf202f5a1875f536d1a31013d8aa6f3945390cf8f9c4f53d2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page