Skip to main content

Explicit, cached subprocess.run for ad-hoc build pipelines.

Project description

reforge

An explicit, cached subprocess.run for ad-hoc build pipelines.

Reforge is a tiny build helper: you write your pipeline as a plain Python script that calls run(...) for each step, and reforge skips steps whose declared inputs haven't changed. No DAG, no rules file, no DSL — just subprocess.run with a content-addressed cache.

Install

pip install reforge-build
# or
uv add reforge-build

The PyPI distribution name is reforge-build (the bare reforge name was already taken on PyPI). The import name is still reforge.

Usage

from reforge import input, output, run

# Inputs and outputs must be declared explicitly.
run(
    "pandoc",
    input("docs/index.md"),
    "-o",
    output("build/index.html"),
)

# stdout/stderr can be captured to declared outputs.
run(
    "python",
    input("scripts/list_things.py"),
    stdout=output("build/things.tsv"),
)

# When an output is a directory containing a known sentinel file,
# pass the sentinel as the second argument so reforge can check it.
run(
    "iqtree2",
    "-s", input("data/aln.fasta"),
    "--prefix", output("build/iqtree/output", ".log"),
)

Rules

  • run(...) executes immediately.
  • Inputs must be wrapped with input(...); missing inputs raise FileNotFoundError.
  • Outputs must be wrapped with output(...); their parent directories are auto-created.
  • A step is skipped only when all declared outputs exist and the fingerprint (command + content hash of every input) matches the cached fingerprint.
  • A step with no inputs always runs — there is no way to fingerprint it safely.
  • Commands run in a fresh temporary working directory, so they can't accidentally read or write relative paths in your tree.
  • Cache metadata lives in .reforge/ at the current working directory.

Note on input

The module exports input and output, which shadow the Python builtin input() when star-imported. If you need the builtin, import it explicitly:

from reforge import input as rf_input, output, run

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

reforge_build-0.1.0.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

reforge_build-0.1.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file reforge_build-0.1.0.tar.gz.

File metadata

  • Download URL: reforge_build-0.1.0.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.1

File hashes

Hashes for reforge_build-0.1.0.tar.gz
Algorithm Hash digest
SHA256 f61fb1c85d5cd1b8ea55d3879fff72ef33864078b268ae835d1afc2f7911a8a0
MD5 bf77524bfbb646f13da1c454e699a259
BLAKE2b-256 1ffce09c36fd9252ddf2a281ee59e9d6b1dfe3328c69cab576d08cfa6f4fac8d

See more details on using hashes here.

File details

Details for the file reforge_build-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for reforge_build-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 490a7f7ada965e9778646f5f706a96b72ec517e074dc418d1418ca2d22c33d3f
MD5 4cb172487cdfa36aac2d409e19f471db
BLAKE2b-256 70ae0907bf41f7736bce72e9f34933eea92137a49f535d548d736017cdcaf575

See more details on using hashes here.

Supported by

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