Skip to main content

Dependency injection without the boilerplate.

Project description

Hatch Build Scripts

PyPI - Version PyPI - Python Version License: MIT

A plugin for Hatch that allows you to run arbitrary build scripts and include their artifacts in your package distributions.

Installation

To set up hatch-build-scripts for your project you'll need to configure it in your project's pyproject.toml file as a build-system requirement:

[build-system]
requires = ["hatchling", "hatch-build-scripts"]
build-backend = "hatchling.build"

Usage

Now you'll need to configure the build scripts you want to run. This is done by adding an array of scripts to the tool.hatch.build.hooks.build-scripts.scripts key in your pyproject.toml file. Each script is configured with the following keys:

Key Default Description
commands required An array of commands to run. Each command is run in a separate shell.
artifacts [] An array of artifact patterns (same as .gitignore) to include in your package distributions.
out_dir "." The directory to copy artifacts into.
work_dir "." The directory to run the commands in. All artifact patterns are relative to this directory.
clean_artifacts true Whether to clean files from the out_dir that match the artifact patterns before running the commands.
clean_out_dir false Whether to clean the out_dir before running the commands.

In practice this looks like:

[[tool.hatch.build.hooks.build-scripts.scripts]]
out_dir = "out"
commands = [
    "echo 'Hello, world!' > hello.txt",
    "echo 'Goodbye, world!' > goodbye.txt",
]
artifacts = [
    "hello.txt",
    "goodbye.txt",
]

[[tool.hatch.build.hooks.build-scripts.scripts]]
# you can add more scripts here...

You can configure script defaults for scripts by adding a [tool.hatch.build.hooks.build-scripts] table to your pyproject.toml file. The following keys are supported:

Key Default Description
out_dir "." The directory to copy artifacts into.
work_dir "." The directory to run the commands in. All artifact patterns are relative to this directory.
clean_artifacts true Whether to clean files from the out_dir that match the artifact patterns before running the commands.
clean_out_dir false Whether to clean the out_dir before running the commands.

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_scripts-1.0.0.tar.gz (7.6 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_scripts-1.0.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file hatch_build_scripts-1.0.0.tar.gz.

File metadata

  • Download URL: hatch_build_scripts-1.0.0.tar.gz
  • Upload date:
  • Size: 7.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.8

File hashes

Hashes for hatch_build_scripts-1.0.0.tar.gz
Algorithm Hash digest
SHA256 563735e2f265c9e1b92dece6f762309114505ffaf6e5d51d462eb6a3b4f14640
MD5 489b369376a59df993c9b6b2a1823fa1
BLAKE2b-256 c794d5364975d18dff4f7b26e0a1623df6a3a74efbb616a509bd6dc051a0a700

See more details on using hashes here.

File details

Details for the file hatch_build_scripts-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hatch_build_scripts-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 22a13deee7213646b13351ed05fe9e47f036565d87d8f23d90d8980a63adb71a
MD5 4ec5dcacd4cbd12e9ddc05ae306e5d83
BLAKE2b-256 bd82c550623f6e76bf567f1cb3a84660e037e603979feaec7b8c88c2138bc64b

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