Skip to main content

tox build (main)

Build status

static analysis

Sonarcloud Quality Gate Sonarcloud bugs

unit test code coverage

Sonarcloud coverage

Python versions supported

Supported Python Versions

latest released version

PyPI Release Version

documentation

Documentation Status

license

MIT license

community/support

OpenCyphal forum

Nunavut is a source-to-source compiler (transpiler) that automatically converts OpenCyphal DSDL definitions into source code in a specified target programming language. It is constructed as a template engine that exposes a PyDSDL abstract syntax tree to Jinja2 templates allowing authors to generate code, schemas, metadata, documentation, etc.

/docs/static/images/nunavut_pipeline.svg

Nunavut DSDL transcompilation pipeline.

Nunavut ships with built-in support for some programming languages, and it can be used to generate code for other languages if custom templates (and some glue logic) are provided. Currently, the following languages are supported out of the box:

  • C11 (generates header-only libraries)

  • C++ (generates header-only libraries; work-in-progress)

  • Python (generates Python packages)

  • HTML (generates documentation pages)

Nunavut is named after the Canadian territory. We chose the name because it is a beautiful word to say and read.

Installation

Nunavut depends on PyDSDL.

Install from PIP:

pip install -U nunavut

Examples

The examples do not replace the documentation, please do endeavor to read it.

Generate C headers using the command-line tool

This example assumes that the public regulated namespace directories reg and uavcan reside under public_regulated_data_types/. Nunavut is invoked to generate code for the former.

nnvg --target-language c --target-endianness=little --enable-serialization-asserts public_regulated_data_types/reg --lookup-dir public_regulated_data_types/uavcan

Generate HTML documentation pages using the command-line tool

See above assumptions. The below commands generate documentation for the reg namespace. Note that we have to generate documentation for the uavcan namespace as well, because there are types in reg that will link to uavcan documentation sections.

nnvg --experimental-languages --target-language html public_regulated_data_types/reg --lookup-dir public_regulated_data_types/uavcan
nnvg --experimental-languages --target-language html public_regulated_data_types/uavcan

Generate Python packages using the command-line tool

This example assumes that the public regulated namespace directories reg and uavcan reside under public_regulated_data_types/. Nunavut is invoked to generate code for the former.

nnvg --target-language py public_regulated_data_types/reg --lookup-dir public_regulated_data_types/uavcan

Use custom templates

Partial example: generating a C struct

   /*
    * Cyphal data structure definition
    *
    * Auto-generated, do not edit.
    *
    * Source file: {{T.source_file_path.as_posix()}}
    */

    #ifndef {{T.full_name | ln.c.macrofy}}
    #define {{T.full_name | ln.c.macrofy}}

    {%- for constant in T.constants %}
    #define {{ T | ln.c.macrofy }}_{{ constant.name | ln.c.macrofy }} {{ constant | constant_value }}
    {%- endfor %}

    typedef struct
    {
        /*
            Note that we're not handling union types properly in this simplified example.
            Unions take a bit more logic to generate correctly.
        */
        {%- for field in T.fields_except_padding %}
            {{ field.data_type | declaration }} {{ field | id }}
            {%- if field.data_type is ArrayType -%}
                [{{ field.data_type.capacity }}]
            {%- endif -%};
        {%- if field is VariableLengthArrayType %}
            {{ typename_unsigned_length }} {{ field | id }}_length;
        {%- endif -%}
        {%- endfor %}
...

    } {{ T | full_reference_name }};

    #endif // {{T.full_name | ln.c.macrofy}}

More examples

Where to find more examples to get started:

  1. See built-in templates under nunavut.lang.LANGUAGE.templates.

  2. API usage examples can be found in the Pycyphal library.

Bundled third-party software

Nunavut embeds the following third-party software libraries into its source (i.e. these are not dependencies and do not need to be installed):

  • Jinja2 by Armin Ronacher and contributors, BSD 3-clause license.

  • markupsafe by Armin Ronacher and contributors, BSD 3-clause license (needed for Jinja).

Documentation

The documentation for Nunavut is hosted on readthedocs.io:

Nunavut is part of the OpenCyphal project:

Release files for nunavut 2.3.1

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

Source distribution (sdist)

Source distribution for nunavut 2.3.1
File Size Uploaded
nunavut-2.3.1.tar.gz 321.0 kB Details

Built distribution (wheel)

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

Total release size: 690.0 kB

Release files / nunavut-2.3.1.tar.gz

Download URL nunavut-2.3.1.tar.gz
Size 321.0 kB
Tags Source
SHA-256 checksum
How to use checksums
db70b76e2514b35d0fa39ab39f71056aae3e1de5825c80ba5b3c4e2b2e7d5603
BLAKE2b-256 checksum
How to use checksums
a381e0be4fc84f3e5b6fad11326f24bb4aee409df753abc8ef898f1d3f958180
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release files / nunavut-2.3.1-6748279276-py3-none-any.whl

Download URL nunavut-2.3.1-6748279276-py3-none-any.whl
Size 369.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c40583e9ef0e4ddadb4f1246cf6193aa2ee9d5f61e4e94eddab6d493246b4c15
BLAKE2b-256 checksum
How to use checksums
2c9bfafdb5e85aef096e0f3dfd4539b65ac8e425c15d0f97d54dfc6fa78da6b3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.10.6

Release history Release notifications | RSS feed

This release

2.3.1 This release

2 release files

2.3.0

2 release files

2.1.1

2 release files

2.1.0

2 release files

2.0.9

2 release files

2.0.8

2 release files

2.0.7

2 release files

2.0.5

2 release files

2.0.4

2 release files

2.0.3

2 release files

2.0.2

2 release files

2.0.1

2 release files

2.0.0

2 release files

1.9.0

2 release files

1.8.3

2 release files

1.8.2

2 release files

1.8.1

2 release files

1.8.0

3 release files

1.7.8

2 release files

1.7.6

2 release files

1.7.5

2 release files

1.7.4

3 release files

1.7.3

2 release files

1.7.2

2 release files

1.7.1

2 release files

1.7.0

2 release files

1.6.2

2 release files

1.6.1

3 release files

1.6.0

2 release files

1.5.2

2 release files

1.5.1

2 release files

1.5.0

2 release files

1.4.2

3 release files

1.4.1

2 release files

1.4.0

2 release files

1.3.0

3 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.3

2 release files

1.0.2

3 release files

1.0.1

3 release files

1.0.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.5

2 release files

0.6.4

2 release files

0.6.3

2 release files

0.6.2

2 release files

0.6.1

2 release files

0.6.0

2 release files

0.5.1

2 release files

0.5.0

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.9

2 release files

0.3.8

2 release files

0.3.7

2 release files

0.3.6

2 release files

0.3.5

2 release files

0.3.4

2 release files

0.3.3

2 release files

0.3.1

2 release files

0.3.0

3 release files

0.2.4

2 release files

0.2.3

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

3 release files

0.1.20

2 release files

0.1.13

2 release files

0.1.11

3 release files

0.1.10

2 release files

0.1.9

3 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

3 release files

0.1.5

2 release files

0.1.4

3 release files

0.1.3

1 release file

0.1.2

1 release file

0.1.1

3 release files

0.1.0

5 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