version.py 931 Bytes
Newer Older
1
2
# SPDX-License-Identifier: Apache-2.0

3
try:
4
    from ._version import __version__, __version_tuple__
5
except Exception as e:
6
7
    import warnings

8
9
10
11
    warnings.warn(f"Failed to read commit hash:\n{e}",
                  RuntimeWarning,
                  stacklevel=2)

12
13
    __version__ = "dev"
    __version_tuple__ = (0, 0, __version__)
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31


def _prev_minor_version_was(version_str):
    """Check whether a given version matches the previous minor version.

    Return True if version_str matches the previous minor version.

    For example - return True if the current version if 0.7.4 and the
    supplied version_str is '0.6'.

    Used for --show-hidden-metrics-for-version.
    """
    # Match anything if this is a dev tree
    if __version_tuple__[0:2] == (0, 0):
        return True

    # Note - this won't do the right thing when we release 1.0!
    return version_str == f"{__version_tuple__[0]}.{__version_tuple__[1] - 1}"