A simple Python-based build system
Project description
buildmgr - A simple Python-based build system
This module lets you define targets, dependencies, and commands in pure Python to manage your project's build workflow, similar to Make.
Usage
-
Define your own targets:
- Use
BuildTargetfor normal build steps: •name: unique identifier •help_msg: short description shown in CLI help •log_msg: message printed when the target runs •commands: list of shell commands (each is aSequence[str|Path]) •dependencies: otherBuildTargetinstances this target relies on •inputs/outputs: files to determine staleness - Use
CleanupTargetto remove files or directories: •patterns: glob patterns to delete •directories:Pathobjects to remove entirely
- Use
-
Customize global behavior:
- Call
get_logger()at import to configure ANSI-colored logging. - Use
global_config.dry_run = Trueto simulate without executing.
- Call
-
Wire up your build graph:
setup = BuildTarget( name="setup", help_msg="Create virtualenv & install dependencies", log_msg="Setting up virtual environment", commands=[ ["python3", "-m", "venv", ".venv"], [Path(".venv/bin/python"), "-m", "pip", "install", "-r", "requirements.txt"], ], outputs=[Path(".venv")], ) build_docs = BuildTarget( name="docs", help_msg="Build Sphinx documentation", log_msg="Generating docs", commands=[["make", "html", "-C", "docs"]], dependencies=[setup], inputs=list(Path("docs").rglob("*.rst")), outputs=[Path("docs/_build/html/index.html")], )
Instantiate and run the build system:
from build import BuildSystem
import sys
all_target = BuildTarget(
name="all",
help_msg="Build everything",
log_msg="Building all targets",
commands=[],
dependencies=[build_docs, /* your other targets here */],
)
system = BuildSystem(
targets=[setup, build_docs, all_target, /* others */],
default=all_target
)
if __name__ == "__main__":
sys.exit(system()) # Parses CLI args, determines outdated targets, and runs them in order
Command-line interface
$ buildmgr [target]
target Name of the target to run (default: 'all')
Options:
-d, --dry-run Show commands but do not execute
-v, --verbose Enable DEBUG-level logging
-q, --quiet Show only WARNING and above
Key features
Incremental builds: only targets whose outputs are missing or older than any inputs will be run.
Automatic dependency topological sort with cycle detection.
ANSI-colored logging with optional verbosity levels.
Easy cleanup via CleanupTarget.
Project details
Release history Release notifications | RSS feed
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 buildmgr-0.1.1.tar.gz.
File metadata
- Download URL: buildmgr-0.1.1.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5d13a8fcee88e5726e309daeff6de2ef9ea0835af1c08895f722a5d36c51ee0c
|
|
| MD5 |
478d2f4e536c5231970b7115311740ad
|
|
| BLAKE2b-256 |
14dbfeb8c621bd1e20992f7410b97165a189408f8ad83c50142ff9b4229b1d5b
|
File details
Details for the file buildmgr-0.1.1-py3-none-any.whl.
File metadata
- Download URL: buildmgr-0.1.1-py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
325f3c6ced01bfa63e869dc57cb1e8bdd3a587582fc55bf496a5d9ee08402d8c
|
|
| MD5 |
29c900dadca1dca2ff88b3e87fc9dd52
|
|
| BLAKE2b-256 |
899b63233f1cff5e21511cf752f62f52dfb3a82d4ca2673d91512b2bd0e80c2e
|