ningen


Nameningen JSON
Version 0.4.0 PyPI version JSON
download
home_pagehttps://github.com/orenbenkiki/ningen.git
SummaryNinja Build Generation
upload_time2022-12-29 14:02:41
maintainer
docs_urlNone
authorOren Ben-Kiki
requires_python>=3.7
licenseMIT license
keywords ninja make
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            Ningen 0.4.0 - Ninja Build Generation
=====================================

.. image:: https://readthedocs.org/projects/ningen/badge/?version=latest
    :target: https://ningen.readthedocs.io/en/latest/?badge=latest
    :alt: 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:

.. code-block:: python

    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()



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/orenbenkiki/ningen.git",
    "name": "ningen",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "ninja,make",
    "author": "Oren Ben-Kiki",
    "author_email": "oren@ben-kiki.org",
    "download_url": "https://files.pythonhosted.org/packages/48/69/e04def032c2f5f304eb51e764003a9efa4693c587a5daf38db7670f0e1ee/ningen-0.4.0.tar.gz",
    "platform": null,
    "description": "Ningen 0.4.0 - Ninja Build Generation\n=====================================\n\n.. image:: https://readthedocs.org/projects/ningen/badge/?version=latest\n    :target: https://ningen.readthedocs.io/en/latest/?badge=latest\n    :alt: Documentation Status\n\nThis package allows a Python script to use file system operations (such as ``glob``) and/or apply\nany other logic (such as reading structured configuration files) to generate a ``build.ninja`` file.\n\nThis isn't intended to replace \"high level\" build systems such as ``cmake``. Rather, think of it as\nreplacing the clunky GNU ``make`` language with Python.\n\nYes, ``ninja`` does provide the ``ninja_syntax`` module which already does this. The added value of\n``ningen`` is:\n\n* Convenience functions for pattern-based build file generation.\n\n* Allow overriding build statements (which complements the pattern-based approach).\n\nInstallation\n------------\n\nJust ``pip install ningen`` (or the equivalent in whatever Python environment you are using).\n\nUsage\n-----\n\nThe ``Writer`` class is similar to the one in ``ninja_syntax``. Two additional utility functions are\nprovided: ``foreach`` for iterating on all combinations of several variables, possibly extracting\nthem from existing file names; and ``expand`` for generating formatted strings using all the\nvariable combinations.\n\nFor example:\n\n.. code-block:: python\n\n    import ningen as ng\n\n    # Similarly to ninja_syntax writer, but internally buffers everything:\n    writer = ng.Writer()\n\n    modes = ['debug', 'release']\n    objects = []\n    writer.rule('compile_debug', ...)\n    writer.rule('compile_release', ...)\n\n    # Ningen provides the \"foreach\" function,\n    # which iterates on existing files and/or variable values:\n    for c in ng.foreach('src/{*name}.cc', mode=modes):\n        objects.append(name)\n        writer.build(f'obj/{c.mode}/{c.name}.o', f'compile_{c.mode}',\n                     inputs=[c.path, ...], ...)\n\n    # Since it buffers the data, ningen allows overriding previous build statements:\n    writer.rule('special_compile_debug', ...)\n    writer.build('obj/debug/special.o', 'special_compile_gcc',\n                 inputs=['src/special.cc', ...], ..., override=True)\n\n    # Ningen also provides the \"expand\" function which formats multiple strings:\n    for mode in modes:\n        writer.build('bin/{mode}/program', f'link_{mode}',\n                     inputs=ng.expand('obj/{mode}/{object}.o',\n                                      mode=mode, object=objects))\n\n    # Actually write the buffered ninja build file (by default, to \"build.ninja\"):\n    writer.write()\n\n\n",
    "bugtrack_url": null,
    "license": "MIT license",
    "summary": "Ninja Build Generation",
    "version": "0.4.0",
    "split_keywords": [
        "ninja",
        "make"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "md5": "e407653c05e3eb0e1d7b31c9346e3fd3",
                "sha256": "553401926f634679b2ab3cab857b0c670e69564c2dd6bdb48667c2a54d2586f7"
            },
            "downloads": -1,
            "filename": "ningen-0.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "e407653c05e3eb0e1d7b31c9346e3fd3",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 13351,
            "upload_time": "2022-12-29T14:02:41",
            "upload_time_iso_8601": "2022-12-29T14:02:41.944457Z",
            "url": "https://files.pythonhosted.org/packages/48/69/e04def032c2f5f304eb51e764003a9efa4693c587a5daf38db7670f0e1ee/ningen-0.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2022-12-29 14:02:41",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "github_user": "orenbenkiki",
    "github_project": "ningen.git",
    "lcname": "ningen"
}
        
Elapsed time: 0.43252s