Skip to content

Commit

Permalink
Fix API version comparison as suggested by Scott, except that we only…
Browse files Browse the repository at this point in the history
… compare the major version
  • Loading branch information
pavel-kirienko committed Aug 9, 2023
1 parent 75a521c commit 197b011
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/nunavut/lang/py/support/nunavut_support.j2
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ if sys.byteorder != "little": # pragma: no cover
"please implement the missing code and submit a pull request upstream, then remove this exception."
)

API_VERSION = 1 # TODO: provide this from Nunavut at code generation time instead of hard-coding in the template.
API_VERSION = {{ nunavut.support.version }}
"""
This is the version of the API that the generated code expects to be available at runtime.
"""
Expand Down
7 changes: 2 additions & 5 deletions src/nunavut/lang/py/templates/base.j2
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,6 @@
# pylint: skip-file
# mypy: warn_unused_ignores=False

{% set REQUIRED_NUNAVUT_SUPPORT_API_VERSION = 1 -%}
{#- This number shall match the corresponding version number in the Nunavut support library. -#}

{% set ARRAY_PRINT_SUMMARIZATION_THRESHOLD = 100 -%}
{#- How many elements in the array trigger summarization rather than full output.
#- Summarization replaces middle elements with an ellipsis. -#}
Expand All @@ -36,9 +33,9 @@ import warnings as _warnings_
import {{ n }}
{%- endfor %}

if _NSAPIV_ != {{REQUIRED_NUNAVUT_SUPPORT_API_VERSION}}:
if _NSAPIV_[0] != {{ nunavut.support.version[0] }}:
raise RuntimeError(
f"Incompatible Nunavut support API version: { _NSAPIV_ } != {{REQUIRED_NUNAVUT_SUPPORT_API_VERSION}}"
f"Incompatible Nunavut support API version: support { _NSAPIV_ }, package {{ nunavut.support.version }}"
)

{%- from 'serialization.j2' import serialize -%}
Expand Down

0 comments on commit 197b011

Please sign in to comment.