Skip to content

Commit a405326

Browse files
Add API_VERSION constant storing the runtime version as a tuple of ints (#49)
* Add API_VERSION constant storing the runtime version as a tuple of ints Part of the fix for kaitai-io/kaitai_struct#804. * Replace shortened GitHub issue ref with full URL (for convenience) Co-authored-by: Petr Pucil <petr.pucil@seznam.cz>
1 parent 349a861 commit a405326

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

kaitaistruct.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,21 @@
55

66
PY2 = sys.version_info[0] == 2
77

8-
# Kaitai Struct runtime streaming API version, defined as per PEP-0396
9-
# standard. Used for two purposes:
10-
#
11-
# * .py files generated by ksc from .ksy check that they import proper
12-
# KS runtime library by this version number;
13-
# * distribution utils (setup.py) use this when packaging for PyPI
14-
#
8+
# Kaitai Struct runtime version, in the format defined by PEP 440.
9+
# Used by our setup.cfg to set the version number in
10+
# packaging/distribution metadata.
11+
# Also used in Python code generated by older ksc versions (0.7 through 0.9)
12+
# to check that the imported runtime is compatible with the generated code.
13+
# Since ksc 0.10, the compatibility check instead uses the API_VERSION constant,
14+
# so that the version string does not need to be parsed at runtime
15+
# (see https://github.com/kaitai-io/kaitai_struct/issues/804).
1516
__version__ = '0.10'
1617

18+
# Kaitai Struct runtime API version, as a tuple of ints.
19+
# Used in generated Python code (since ksc 0.10) to check that the imported
20+
# runtime is compatible with the generated code.
21+
API_VERSION = (0, 10)
22+
1723

1824
class KaitaiStruct(object):
1925
def __init__(self, stream):

0 commit comments

Comments
 (0)