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 - 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.
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
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 python make.py # Build default target
uv run python make.py clean # Run the clean task
uv run python make.py -w 4 # Build with 4 parallel workers
uv run python make.py -r # Force rebuild all
uv run python make.py -h # Show help with target docs
uv run python make.py -l # List all available targets
-h displays usage information along with target documentation extracted from docstrings:
$ uv run python 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 python 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.1.0.tar.gz.
File metadata
- Download URL: chorelib-0.1.0.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2150c124007cfdcb71d1afe85ac482a08a51e7546f40e19e2c01ada3ebe7d3c9
|
|
| MD5 |
904e9e86b1dacc5b6d36b2f66e0085cf
|
|
| BLAKE2b-256 |
078f9f133243c9266b22f14a0eae7b1009abbe44474f7eddae3f24fe4b4919ab
|
File details
Details for the file chorelib-0.1.0-py3-none-any.whl.
File metadata
- Download URL: chorelib-0.1.0-py3-none-any.whl
- Upload date:
- Size: 20.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
573489f6508dfa6deba74954f7ae7f956cc52a7de61a88cfad729ef8d17d2382
|
|
| MD5 |
fc01f42e819a5bfce1ebcbc4f8d38caa
|
|
| BLAKE2b-256 |
881365bc57571b384ffdad08e691a156a9bf8b63799206075a8b0c9ead5e327f
|