Skip to content

Add API_VERSION constant storing the runtime version as a tuple of ints #49

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

Merged
merged 2 commits into from
Apr 9, 2022

Conversation

dgelessus
Copy link
Contributor

@dgelessus dgelessus commented Aug 18, 2020

Part of one of the potential fixes for kaitai-io/kaitai_struct#804.

@dgelessus
Copy link
Contributor Author

Since this topic came up again in #62 - any objections to merging this (followed by kaitai-io/kaitai_struct_compiler#208)? I don't remember all of the details of the long discussion in kaitai-io/kaitai_struct#804, but IIRC there were no strong objections to this solution.

@dgelessus
Copy link
Contributor Author

Actually, I need to update this first to bump all of the version numbers. I created this PR before the release of KS 0.9, so all of the comments still say 0.9 and not 0.10.

@KOLANICH
Copy link
Contributor

IMHO the symbol should either start with underscore or have KAITAI in the beginning of the name. And __version__ string should be generated automatically.

@dgelessus
Copy link
Contributor Author

IMHO the symbol should either start with underscore or have KAITAI in the beginning of the name.

Why do you think the name should be changed this way?

An underscore would be misleading. API_VERSION is not an internal variable - quite the opposite, it will be used by ksc-generated code, so it has to be kept stable in future versions of the runtime. An extra KAITAI prefix would be redundant IMO, because the attribute is already namespaced under the kaitaistruct module, so there should be no confusion about which API version it's referring to.

IMHO the symbol should either start with underscore or have KAITAI in the beginning of the name. And __version__ string should be generated automatically.

I don't think we can do that. The __version__ value needs to be a string literal in the source code, so that setuptools can statically extract the version number from the code (for the attr: kaitaistruct.__version__ directive in setup.cfg).

@dgelessus
Copy link
Contributor Author

Rebased on top of #64 to update the Kaitai Struct version number.

@KOLANICH
Copy link
Contributor

KOLANICH commented Nov 21, 2021

so that setuptools can statically extract the version number from the code (for the attr: kaitaistruct.__version__ directive in setup.cfg).

I am not sure it does it statically, for static extraction there is read_version package.

@dgelessus
Copy link
Contributor Author

I am not sure it does it statically, for static extraction there is read_version package.

setuptools 46.4.0 and later will parse attribute values statically if possible. If that fails, it still falls back to importing the module, but I would like to avoid that if possible.

Copy link
Member

@generalmimon generalmimon left a comment

Choose a reason for hiding this comment

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

@dgelessus LGTM, thanks!

@generalmimon generalmimon merged commit a405326 into kaitai-io:master Apr 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants