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.4.2.tar.gz (14.8 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.4.2-py3-none-any.whl (15.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hatch_build-0.4.2.tar.gz
  • Upload date:
  • Size: 14.8 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.4.2.tar.gz
Algorithm Hash digest
SHA256 0e8a51864a3d615927ee80aeec02531852beb8d9bd8da5bb72f98ec6fd553a81
MD5 2908a8b02ac544984598ff7f35e9fe71
BLAKE2b-256 774417edec8a35c0ca8b0e048b4c11b11b640df61574004900ceb094ce208b9c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hatch_build-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 15.6 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.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 28ecb88a853367aa3b067ce0f95196027b8e7bfa78bfc9e9f2c3867b687562cc
MD5 88d1d13a4396fbbb89482e49c102d539
BLAKE2b-256 f780efc8d57e484f7b1a0ed690c07a989afe3892d539039d23a782ed88d4cbc6

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