Python build automation framework with decorator-based DSL
Project description
chorelib
A Python build automation framework — like Make, but in Python. chorelib focuses on keeping Make-style speed and rebuild behavior while letting you write build logic in real Python.
chorelib uses a decorator-based DSL for defining build rules and tasks, with dependency management, parallel execution, and mtime-based rebuild detection.
Features
- Decorator-based DSL — Define build rules with
@ruleand tasks with@task, using familiar Python syntax - Regex target patterns — Match multiple targets with regex and use backreferences (
\1) in dependency specifications - Async parallel execution — Run independent build steps concurrently with configurable worker count
- mtime-based rebuild — Skip up-to-date targets automatically, just like Make
- Custom mtime functions — Override mtime checking per target pattern to manage non-file resources (databases, S3 objects, etc.)
- Order-only prerequisites —
needsdependencies ensure build order without triggering rebuilds - Auto-generated help —
-hshows usage with target documentation from docstrings,-llists all available targets - Custom command-line options — Subclass
Mainto add your ownargparseoptions for build configuration - Zero dependencies — Pure Python, no external packages required
Best for: developers who want Make-like rebuild behavior but need Python for complex logic or non-file resources. It also works well as a simple task runner for everyday scripts.
Documentation
Full documentation is available at https://chorelib.readthedocs.io/en/latest/
Installation
pip install chorelib
Quick Start
Here is a Makefile and its chorelib equivalent side by side.
Makefile:
CC=gcc
CFLAGS=-I.
DEPS = hello.h
OBJS = main.o hello.o
.PHONY: clean
%.o: %.c $(DEPS)
$(CC) -c -o $@ $< $(CFLAGS)
hello.exe: $(OBJS)
$(CC) -o $@ $^
clean:
rm -f $(OBJS) hello.exe
chorelib (make.py):
import re
from chorelib import Main, command, rule, task
main = Main()
APP = "hello.exe"
CC = "gcc"
CFLAGS = ["-c", "-I."]
DEPS = ["hello.h"]
OBJS = ["hello.o", "main.o"]
@rule(APP, depends=OBJS, default=True)
def link(target, deps, needs):
"""Build executable"""
command(CC, "-o", target, deps)
@rule(re.compile(r"(.+)\.o"), depends=(r"\1.c", DEPS))
def compile(target, deps, needs):
command(CC, "-o", target, deps[0], CFLAGS)
@task
def clean():
"""Remove the built files."""
command("rm", "-f", OBJS, APP)
if __name__ == "__main__":
main.run()
uv run make.py # Build default target
uv run make.py clean # Run the clean task
uv run make.py -w 4 # Build with 4 parallel workers
uv run make.py -r # Force rebuild all
uv run make.py -h # Show help with target docs
uv run make.py -l # List all available targets
-h displays usage information along with target documentation extracted from docstrings:
$ uv run make.py -h
usage: make.py [-h] [-C DIRECTORY] [-w WORKERS] [-r] [-l] [-v] [-V] [targets ...]
Sample build script for building a C program using chorelib.
hello.exe [default]:
Build executable
clean:
Remove the built files.
rebuild:
Clean and rebuild all files.
execute:
Rebuild and execute the program.
...
-l lists all registered targets with their types, dependencies, and builder functions:
$ uv run make.py -l
[rule] hello.exe:
depends: hello.o, main.o
needs:
function: link
[rule] re: (.+)\.o:
depends: \1.c, hello.h
needs:
function: compile
[task] clean:
needs:
builder: clean
...
Why chorelib over Make?
| Make | chorelib | |
|---|---|---|
| Pattern rules | %.o: %.c |
r"^(.+)\.o" with backreferences |
| Variables & logic | Limited macro language | Full Python |
| Parallel builds | make -j4 |
python make.py -w 4 |
| Non-file targets | .PHONY |
@task decorator |
| Custom mtime | Not supported | @mtime decorator for databases, remote objects, etc. |
| Dependencies | File-only | Files, functions, or any callable |
License
MIT
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file chorelib-0.2.0.tar.gz.
File metadata
- Download URL: chorelib-0.2.0.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ddbc97aafdb7fca28ef5371f1e8208226459cc76fe0099b652cf9e002c672722
|
|
| MD5 |
c3a1908296be14a476c0487be6101b94
|
|
| BLAKE2b-256 |
311044166aae29e45bdd46bfc54af6622ea9db830c4735cb903b427397f76949
|
Provenance
The following attestation bundles were made for chorelib-0.2.0.tar.gz:
Publisher:
publish.yml on atsuoishimoto/chorelib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
chorelib-0.2.0.tar.gz -
Subject digest:
ddbc97aafdb7fca28ef5371f1e8208226459cc76fe0099b652cf9e002c672722 - Sigstore transparency entry: 977456527
- Sigstore integration time:
-
Permalink:
atsuoishimoto/chorelib@b376a467c3457bb8f33e80335af081a5c502b014 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/atsuoishimoto
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b376a467c3457bb8f33e80335af081a5c502b014 -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file chorelib-0.2.0-py3-none-any.whl.
File metadata
- Download URL: chorelib-0.2.0-py3-none-any.whl
- Upload date:
- Size: 19.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b474ca8b1c5b3ebe3bb794d22b4c93b933a6094a7506ed5f60f73f2b1a583e41
|
|
| MD5 |
2dc221ca751be29486d548dcd9c098bf
|
|
| BLAKE2b-256 |
10f93ce7758d3bcc72ffc25d3c4cc3c1d6ac55aee968e77c5e91bba6f4379549
|
Provenance
The following attestation bundles were made for chorelib-0.2.0-py3-none-any.whl:
Publisher:
publish.yml on atsuoishimoto/chorelib
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
chorelib-0.2.0-py3-none-any.whl -
Subject digest:
b474ca8b1c5b3ebe3bb794d22b4c93b933a6094a7506ed5f60f73f2b1a583e41 - Sigstore transparency entry: 977456529
- Sigstore integration time:
-
Permalink:
atsuoishimoto/chorelib@b376a467c3457bb8f33e80335af081a5c502b014 -
Branch / Tag:
refs/tags/v0.2.0 - Owner: https://github.com/atsuoishimoto
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b376a467c3457bb8f33e80335af081a5c502b014 -
Trigger Event:
workflow_dispatch
-
Statement type: