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.1.tar.gz (14.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.4.1-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hatch_build-0.4.1.tar.gz
  • Upload date:
  • Size: 14.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.4.1.tar.gz
Algorithm Hash digest
SHA256 00062bf57e74051777ff7436fdaf3eb045ccc30d08d066eb2ff4415f204edd7a
MD5 94c610fdd8cd59d7dc830de6d7981d60
BLAKE2b-256 ec0190c2e67dc5c1ee12a8307cc67b38a34ad86b1c1bfecced24b3beef97ce75

See more details on using hashes here.

File details

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

File metadata

  • Download URL: hatch_build-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 15.2 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ccdcf13499020a23936f7823b03630bc0af8d4204afedca704cae26ed50fb61e
MD5 93b057769b0d501b1c9fd10d34ab8f66
BLAKE2b-256 6737ccd3e3f9debfb098c60a02a083011a82ad40ff0eb1c713ee59a2661fc1b1

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