A plugin for Hatch for writing build scripts
Project description
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 |
required | 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
Built Distribution
Hashes for hatch_build_scripts-0.0.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74044494aa8f79283e46bc56da10fb821b3246f5d6d5fbe17e1fb0104804a042 |
|
MD5 | 7122c93130ee07d5fdf3c04ffc82610a |
|
BLAKE2b-256 | 6040eba4063cdfeede304fcfe7fc5c0feeecef9453a69760fa8e83db45f56ef6 |
Hashes for hatch_build_scripts-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb1a519c2f616b9dd6a4515b7fa80b4998fd3a0f0a3fd4777e05b8fc8592bfa6 |
|
MD5 | e52e0d37604ee2372dba343ea4206956 |
|
BLAKE2b-256 | 47807a1dd41e312e3f9505b69ecf70fdca8452962668a77b4af0f45733aa91ec |