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
File details
Details for the file hatch_build_scripts-0.0.4.tar.gz
.
File metadata
- Download URL: hatch_build_scripts-0.0.4.tar.gz
- Upload date:
- Size: 8.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.24.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c78520986907e47538f2cbb24fde41edfc2cc55f452b5362fbae15ce4e6344f7 |
|
MD5 | 567766d3529de6a7fd53f269c6e897e2 |
|
BLAKE2b-256 | 6bc287097d54f22105b79c5166c7f279324da7b279cb1679366d5f5c9976a814 |
File details
Details for the file hatch_build_scripts-0.0.4-py3-none-any.whl
.
File metadata
- Download URL: hatch_build_scripts-0.0.4-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: python-httpx/0.24.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 12a2e3c716ba1ec2d249cff6c8e6975b183f446b98f80ccbffec2c707f307470 |
|
MD5 | 7f2ea7dda6e84661e32690ff1a8556ce |
|
BLAKE2b-256 | 4322433e20bdf36074f6c0563ee05240aaf82c2e5ccc5e8cf758793225510e3b |