Skip to main content

Ningen 0.4.0 - Ninja Build Generation

Documentation Status

This package allows a Python script to use file system operations (such as glob) and/or apply any other logic (such as reading structured configuration files) to generate a build.ninja file.

This isn’t intended to replace “high level” build systems such as cmake. Rather, think of it as replacing the clunky GNU make language with Python.

Yes, ninja does provide the ninja_syntax module which already does this. The added value of ningen is:

  • Convenience functions for pattern-based build file generation.

  • Allow overriding build statements (which complements the pattern-based approach).

Installation

Just pip install ningen (or the equivalent in whatever Python environment you are using).

Usage

The Writer class is similar to the one in ninja_syntax. Two additional utility functions are provided: foreach for iterating on all combinations of several variables, possibly extracting them from existing file names; and expand for generating formatted strings using all the variable combinations.

For example:

import ningen as ng

# Similarly to ninja_syntax writer, but internally buffers everything:
writer = ng.Writer()

modes = ['debug', 'release']
objects = []
writer.rule('compile_debug', ...)
writer.rule('compile_release', ...)

# Ningen provides the "foreach" function,
# which iterates on existing files and/or variable values:
for c in ng.foreach('src/{*name}.cc', mode=modes):
    objects.append(name)
    writer.build(f'obj/{c.mode}/{c.name}.o', f'compile_{c.mode}',
                 inputs=[c.path, ...], ...)

# Since it buffers the data, ningen allows overriding previous build statements:
writer.rule('special_compile_debug', ...)
writer.build('obj/debug/special.o', 'special_compile_gcc',
             inputs=['src/special.cc', ...], ..., override=True)

# Ningen also provides the "expand" function which formats multiple strings:
for mode in modes:
    writer.build('bin/{mode}/program', f'link_{mode}',
                 inputs=ng.expand('obj/{mode}/{object}.o',
                                  mode=mode, object=objects))

# Actually write the buffered ninja build file (by default, to "build.ninja"):
writer.write()

Metadata

Release files for ningen 0.4.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 ningen 0.4.0
File Size Uploaded Provenance
ningen-0.4.0.tar.gz 13.4 kB Without provenance Details

Release files / ningen-0.4.0.tar.gz

Download URL ningen-0.4.0.tar.gz
Size 13.4 kB
Tags Source
SHA-256 checksum
How to use checksums
553401926f634679b2ab3cab857b0c670e69564c2dd6bdb48667c2a54d2586f7
BLAKE2b-256 checksum
How to use checksums
4869e04def032c2f5f304eb51e764003a9efa4693c587a5daf38db7670f0e1ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.6.0 importlib_metadata/4.12.0 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.7.12

Security for ningen 0.4.0

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.4.0 This release

1 release file No provenance

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