Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/rmorshea/hatch-build-scripts
A plugin for Hatch that runs build scripts and saves their artifacts.
https://github.com/rmorshea/hatch-build-scripts
Last synced: 13 days ago
JSON representation
A plugin for Hatch that runs build scripts and saves their artifacts.
- Host: GitHub
- URL: https://github.com/rmorshea/hatch-build-scripts
- Owner: rmorshea
- License: mit
- Created: 2023-05-29T07:39:30.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-02-04T17:41:58.000Z (9 months ago)
- Last Synced: 2024-10-07T09:34:47.311Z (about 1 month ago)
- Language: Python
- Size: 35.2 KB
- Stars: 12
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Hatch Build Scripts
A plugin for [Hatch](https://github.com/pypa/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:```toml
[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:
```toml
[[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. |