Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Python codegen #306

Merged
merged 36 commits into from
Aug 18, 2023
Merged

Add Python codegen #306

merged 36 commits into from
Aug 18, 2023

Conversation

pavel-kirienko
Copy link
Member

@pavel-kirienko pavel-kirienko commented May 21, 2023

Functionally this is complete and ready for review (sans possible minor CI issues), but the following will need to be completed before this is ready for merging:

  • Secure Scott's blessing of the proposed verification suite arrangement. Please consult with verification/python/README.md.
  • Fix some minor testing-related shortcomings.
  • Add docs.

The codegen templates do not need review as they have been transplanted as-is from PyCyphal. Same goes for the tests themselves.

This changeset also drops support for Python 3.6.

Fixes OpenCyphal/pycyphal#110
Required for OpenCyphal/pycyphal#277
Supersedes #234

@pavel-kirienko pavel-kirienko added feature New feature or request major A major issue that should be a priority labels May 21, 2023
@pavel-kirienko pavel-kirienko self-assigned this May 21, 2023
…'s own scaffolding, otherwise things get a bit complicated. It is currently not being tested due to the renaming, this will be fixed next.
@pavel-kirienko pavel-kirienko marked this pull request as draft May 21, 2023 20:37
@pavel-kirienko
Copy link
Member Author

I would like to pass the value of __version__ defined in nunavut.lang.py.templates to the template context so that I could compare the major version number defined in nunavut_support.py against the version expected by the code generated for a data type. This would be similar to nunavut.version except the version number should be that of the templates. I see that this is supposed to be done via LanguageTemplateNamespace but I don't quite understand the idiomatic way of doing this without altering Nunavut's internals. @thirtytwobits what would be the correct way to go about this?

@pavel-kirienko pavel-kirienko marked this pull request as ready for review May 22, 2023 12:59
Copy link
Member

@thirtytwobits thirtytwobits left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not super-thrilled with all the jinja macros (I prefer writing as much code as possible in Python as filters, tests, or other objects) but the results are looking really good.

At some point we'll want to generate python<->c bindings. Do you foresee that being disruptive to the current design of your python?

README.rst Outdated Show resolved Hide resolved
docs/languages.rst Outdated Show resolved Hide resolved
docs/languages.rst Show resolved Hide resolved
src/nunavut/lang/py/__init__.py Outdated Show resolved Hide resolved
src/nunavut/lang/py/templates/base.j2 Outdated Show resolved Hide resolved
src/nunavut/lang/py/templates/base.j2 Outdated Show resolved Hide resolved
src/nunavut/lang/py/templates/base.j2 Show resolved Hide resolved
src/nunavut/lang/py/templates/base.j2 Show resolved Hide resolved
src/nunavut/lang/py/templates/base.j2 Show resolved Hide resolved
@pavel-kirienko pavel-kirienko force-pushed the python-codegen branch 4 times, most recently from eb62ef3 to c65cabc Compare August 10, 2023 14:03
@pavel-kirienko
Copy link
Member Author

pavel-kirienko commented Aug 10, 2023

I fixed the ReadTheDocs build issue in the last commit: e6b7c25

The commit adds the RTD config file .readthedocs.yaml specifying a modern Python version. Unfortunately, the change made the ReadTheDocs website unable to find the index.html document in the output root, and indeed it was missing. The least intrusive way to fix that was to lift the index.rst file from docs/ to the root of the repository. This is not pretty and I think a better solution is to actually move all docs-related things down into docs/, including conf.py and requirements.txt, but this is a very invasive change that alters a lot of things (and causes Sphinx to crash with an obscure internal error).

For now, I left it in this state as this is meant to be a quick fix; perhaps we can revisit this later.

@sonarcloud
Copy link

sonarcloud bot commented Aug 18, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

96.6% 96.6% Coverage
0.0% 0.0% Duplication

@pavel-kirienko pavel-kirienko merged commit b2a82de into main Aug 18, 2023
182 checks passed
@pavel-kirienko pavel-kirienko deleted the python-codegen branch August 18, 2023 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request major A major issue that should be a priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Move the DSDL package generator to Nunavut
2 participants