Hatch Build Scripts
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. |
Metadata
Release files for hatch_build_scripts 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| hatch_build_scripts-1.0.0.tar.gz | 7.6 kB | Without provenance | Details for hatch_build_scripts-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hatch_build_scripts-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for hatch_build_scripts-1.0.0-py3-none-any.whl |
Total release size: 14.1 kB
Release files / hatch_build_scripts-1.0.0.tar.gz
| Download URL | hatch_build_scripts-1.0.0.tar.gz |
|---|---|
| Size | 7.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
563735e2f265c9e1b92dece6f762309114505ffaf6e5d51d462eb6a3b4f14640
|
|
BLAKE2b-256 checksum How to use checksums |
c794d5364975d18dff4f7b26e0a1623df6a3a74efbb616a509bd6dc051a0a700
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.8
|
Release files / hatch_build_scripts-1.0.0-py3-none-any.whl
| Download URL | hatch_build_scripts-1.0.0-py3-none-any.whl |
|---|---|
| Size | 6.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
22a13deee7213646b13351ed05fe9e47f036565d87d8f23d90d8980a63adb71a
|
|
BLAKE2b-256 checksum How to use checksums |
bd82c550623f6e76bf567f1cb3a84660e037e603979feaec7b8c88c2138bc64b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.7.8
|
Security for hatch_build_scripts 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.