Skip to content

Development module

The Development module implements features useful for developing Boldi's Python libraries. It is only a dev dependency of the main boldi Python package, not a regular dependency, like the other packages.

Install

Boldi's Development module is distributed as the boldi-dev Python package, thus to install it, run:

pip install boldi-dev

...or add "boldi-dev" as a dependency to your project.

Run

Boldi's Development module defines extensions to the boldi CLI, so to use it, run the following command:

boldi dev --help

The boldi dev command is only available if the boldi-dev package is installed.

boldi dev

This commands shows the help message for the other boldi dev subcommands.

boldi dev docs

Generated the docs for Boldi's Python libraries.

boldi dev package

Builds the Python packages for Boldi's Python libraries.

API

boldi.dev

cli_dev(ctx: CliCtx, subparser: ArgumentParser)

Source code in pkg/boldi-dev/boldi/dev.py
def cli_dev(ctx: CliCtx, subparser: ArgumentParser):
    subparser.usage = "run a dev command"
    dev_subparsers = subparser.add_subparsers()

    subparser_package = dev_subparsers.add_parser("package")
    subparser_package.set_defaults(action=partial(cli_dev_package, ctx))
    subparser_package.add_argument("--only-include", "-i", nargs="+", default=[], help="only include these packages")

    subparser_docs = dev_subparsers.add_parser("docs")
    subparser_docs.set_defaults(action=partial(cli_dev_docs, ctx))

cli_dev_docs(ctx: CliCtx)

Source code in pkg/boldi-dev/boldi/dev.py
def cli_dev_docs(ctx: CliCtx):
    if root := first_parent_where(ctx.cwd, lambda parent: (parent / "mkdocs.yml").is_file()):
        ctx.run_py("-m mkdocs build", cwd=root)

cli_dev_package(ctx: CliCtx, only_include: list[str])

Source code in pkg/boldi-dev/boldi/dev.py
def cli_dev_package(ctx: CliCtx, only_include: list[str]):
    if root := first_parent_where(ctx.cwd, lambda parent: (parent / ".git").is_dir()):
        only_include_set = set(only_include)
        for pkg in sorted((root / "pkg").iterdir()):
            should_include = not only_include_set or pkg.name in only_include_set
            is_package = pkg.is_dir() and (pkg / "pyproject.toml").is_file()
            if should_include and is_package:
                ctx.run_py("-m build --no-isolation --sdist --wheel", ["--outdir", root / "dist"], cwd=pkg)

first_parent_where(dir: Path, predicate: Callable[[Path], bool]) -> Path | None

Source code in pkg/boldi-dev/boldi/dev.py
def first_parent_where(dir: Path, predicate: Callable[[Path], bool]) -> Path | None:
    return next(filter(predicate, chain([dir], dir.parents)), None)