# Nunavut Python Library to use SupportGenerator

**URL:** <https://forum.opencyphal.org/t/nunavut-python-library-to-use-supportgenerator/1703>\
**Category:** Nunavut\
**Created:** [July 6, 2022, 4:01pm UTC](https://forum.opencyphal.org/t/nunavut-python-library-to-use-supportgenerator/1703 "2022-07-06T16:01:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![pat1](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/p/43a26b/32.png) [@pat1](https://forum.opencyphal.org/u/pat1)\
**Post date:** [July 6, 2022, 4:01pm UTC](https://forum.opencyphal.org/t/nunavut-python-library-to-use-supportgenerator/1703/1 "2022-07-06T16:01:03Z")

</div>

I am trying to use nunavut python library to generate support includes as I do from command line like:  
nnvg --target-language c -O include --target-endianness little --generate-support only"

I am trying code like this but it do not generate any code:

```auto
from pydsdl import read_namespace
from nunavut import build_namespace_tree
from nunavut.lang import LanguageContext
from nunavut.jinja import DSDLCodeGenerator, SupportGenerator
from pathlib import Path

root_namespace_dir_uavcan = "data_types/uavcan"
root_namespace_dir_reg = "data_types/reg"
out_dir = "include"

lookup_directories = [root_namespace_dir_uavcan,root_namespace_dir_reg]

# parse the dsdl
compound_types = read_namespace(root_namespace_dir_reg, lookup_directories)

# select a target language
language_context = LanguageContext('c')

# build the namespace tree
root_namespace = build_namespace_tree(compound_types,
                                      root_namespace_dir_reg,
                                      out_dir,
                                      language_context)

root_namespace.base_output_path = "include"
print(root_namespace.get_support_output_folder())
support_generator = SupportGenerator(root_namespace)
print(support_generator.get_templates())
support_generator.generate_all()

```

Thanks for any suggestion

---

<div class="post-metadata">

**Author:** ![scottdixon](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/scottdixon/32/39_2.png) [@scottdixon](https://forum.opencyphal.org/u/scottdixon)\
**Post date:** [July 6, 2022, 6:06pm UTC](https://forum.opencyphal.org/t/nunavut-python-library-to-use-supportgenerator/1703/2 "2022-07-06T18:06:03Z")

</div>

Let me take a look…

---

<div class="post-metadata">

**Author:** ![scottdixon](https://forum.opencyphal.org/user_avatar/forum.opencyphal.org/scottdixon/32/39_2.png) [@scottdixon](https://forum.opencyphal.org/u/scottdixon)\
**Post date:** [July 6, 2022, 7:08pm UTC](https://forum.opencyphal.org/t/nunavut-python-library-to-use-supportgenerator/1703/3 "2022-07-06T19:08:47Z")

</div>

Sorry for the delay. There is a helper in `nunavut/ __init__.py` that isn’t often used that will do all this for you:

```auto
from nunavut import generate_types

generate_types("cpp", "submodules/public_regulated_data_types/uavcan", "fooout", omit_serialization_support=False)

```

That said, this doesn’t allows to to specify “support only.” If I created a new version of this helper that was for support-only generation would you want to use that?

Otherwise just look at the implementation of the [generate\_types](https://github.com/OpenCyphal/nunavut/blob/main/src/nunavut/ __init__.py#L437) method and note that `c` does not have any support files unless you enable serialization (`omit_serialization_support=False`, It’s odd that I made the default True. That also is something I should fix).

---

<div class="post-metadata">

**Author:** ![pat1](https://forum.opencyphal.org/letter_avatar_proxy/v4/letter/p/43a26b/32.png) [@pat1](https://forum.opencyphal.org/u/pat1)\
**Post date:** [July 6, 2022, 8:16pm UTC](https://forum.opencyphal.org/t/nunavut-python-library-to-use-supportgenerator/1703/4 "2022-07-06T20:16:13Z")

</div>

This code:

```auto
from nunavut import generate_types

generate_types("c", "data_types/uavcan", "include", omit_serialization_support=False)
generate_types("c", "data_types/reg", "include", omit_serialization_support=False, lookup_directories=["data_types/uavcan",])

```

make what I need.

Thaks a lot!
