Skip to main content

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 run the commands in.
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 run the commands in.
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-0.0.2.tar.gz (7.8 kB view details)

Uploaded Source

Built Distribution

hatch_build_scripts-0.0.2-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: hatch_build_scripts-0.0.2.tar.gz
  • Upload date:
  • Size: 7.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-httpx/0.24.1

File hashes

Hashes for hatch_build_scripts-0.0.2.tar.gz
Algorithm Hash digest
SHA256 b849391f9b026145a2873a74ff8bf6ebf1e10dcc3fed2bfc1ae8027d1387694b
MD5 903c1f58bb1ca562551e653832677ca7
BLAKE2b-256 b887e073d328f858031d3e5b88c7af9639ddd7fef77a60d459932b1f0a6ad1e8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for hatch_build_scripts-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 976e6b750ba1f29e43920a219d524b8f37c215c9d12d94353f370d9cf365e488
MD5 e719127d51bfe843ad7a79214a8b1bf7
BLAKE2b-256 485d2e0046530992270482584cf48168537f0ee2456e98abd094f48377c6be6f

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page