Skip to main content

Miniscons

SCons builders.

Review Version Downloads Quality Coverage

Motivation

When writing an SConstruct.py configuration it is difficult to:

  • Specify libraries and warnings for each build since the default environment is global
  • Declare executable targets that depend on builds and don't need to be built themselves
  • Parse outputs from conan to get include paths for build dependencies since they don't appear in the exported conandeps
  • Declare and chain together aliases for external scripts

We can use miniscons to keep the SConstruct.py file short and get an interface like this:

builds:
  build
  tests

targets:
  start -> build
  test -> tests

scripts:
  tidy
  clean

routines:
  lint -> [tidy, clean]

flags:
  --dump

Installing

pip install miniscons

Documentation

Documentation and more detailed examples are hosted on Github Pages.

 Usage

Parse the SConscript_conandeps if you are using conan:

from miniscons import conan

env = conan()

Add the builds with their specific warning flags and libs to include:

from miniscons import Build, flags, packages
from walkmate import tree

build = Build(
    "build",
    tree("src", r"(?<!\.spec)\.cpp$"),
    flags("c++11", ["shadow"]),
)

tests = Build(
    "tests",
    tree("src", r"\.cpp$", ["main.cpp"]),
    flags("c++11"),
    packages(["gtest"]),
)

Add the executable targets that depend on the builds with their runtime arguments:

from miniscons import Target

start = Target("start", build)

test = Target("test", tests, ["--gtest_brief"])

Add the scripts to invoke your tooling:

from miniscons import Script
from walkmate import tree

includes = tests.packages["CPPPATH"]

clean = Script(
    "cppclean",
    ["cppclean", "."],
)

tidy = Script(
    "clang-tidy",
    [
        "clang-tidy",
        tree("src", r"\.(cpp)$"),
        "--",
        [f"-I{i}" for i in includes],
    ],
)

Add the routines and flags for your interface:

from miniscons import Flag, Routine

lint = Routine("lint", [clean, tidy])

dump = Flag("--dump")

Register all the declarations with the environment and add handlers for each flag:

from miniscons import Tasks
from SCons.Script.Main import GetOption

cli = Tasks(
    [build, tests],
    [start, test],
    [tidy, clean],
    [lint],
    [dump],
)

cli.register(env)

if GetOption("dump"):
    cli.dump()

Now if we run

scons --dump

We get our interface:

scons: Reading SConscript files ...

builds:
  build
  tests

targets:
  start -> build
  test -> tests

scripts:
  tidy
  clean

routines:
  lint -> [tidy, clean]

flags:
  --dump

Discussion

Why not use a simple task runner for scripts and routines?

Some scripts need access to the include paths that appear in the SConstruct.py file so they need to be integrated into the scons workflow.

Tooling

Dependencies

To install dependencies:

yarn install
pip install .[all]

Tests

To run tests:

thx test

Documentation

To generate the documentation locally:

thx docs

Linters

To run linters:

thx lint

Formatters

To run formatters:

thx format

Contributing

Please read this repository's Code of Conduct which outlines our collaboration standards and the Changelog for details on breaking changes that have been made.

This repository adheres to semantic versioning standards. For more information on semantic versioning visit SemVer.

Bump2version is used to version and tag changes. For example:

bump2version patch

Contributors

Remarks

Lots of love to the open source community!

Be kind to your mind Love each other It's ok to have a bad day

Metadata

Release files for miniscons 0.13.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for miniscons 0.13.0
File Size Uploaded
miniscons-0.13.0.tar.gz 6.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for miniscons 0.13.0
File Interpreter ABI Platform
miniscons-0.13.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.2 kB

Release files / miniscons-0.13.0.tar.gz

Download URL miniscons-0.13.0.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
797132628901cffea418ed96a2abc805b7e304bcddb472c1cb60e3a09357328c
BLAKE2b-256 checksum
How to use checksums
5e31682dd6b4c58e5b52fbf8b53d6b623680c7236d993833d49214f308f65c1f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 21, 2025.

Transparency log

Release files / miniscons-0.13.0-py3-none-any.whl

Download URL miniscons-0.13.0-py3-none-any.whl
Size 9.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
710b4ec04997a3ffc106dd65465bcb9cc7e8b8f47b5a03fdf30d32f41672ae4d
BLAKE2b-256 checksum
How to use checksums
41f20454966eaa34c7db0c9e15cf895ff836b69730dd4620bfff4fa0932bf904
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 21, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

0.13.0 This release

2 release files

0.12.0

2 release files

0.11.3

2 release files

0.11.0

2 release files

0.10.2

2 release files

0.6.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page