version.py 1.34 KB
Newer Older
lizhigong's avatar
lizhigong committed
1
2
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3

4
try:
lizhigong's avatar
lizhigong committed
5
    from ._version import __version__, __version_tuple__
6
except Exception as e:
7
8
    import warnings

lizhigong's avatar
lizhigong committed
9
    warnings.warn(f"Failed to read commit hash:\n{e}",
10
11
                  RuntimeWarning,
                  stacklevel=2)
lizhigong's avatar
lizhigong committed
12

13
14
    __version__ = "dev"
    __version_tuple__ = (0, 0, __version__)
lizhigong's avatar
lizhigong committed
15
16


17
def _prev_minor_version_was(version_str):
lizhigong's avatar
lizhigong committed
18
    """Check whether a given version matches the previous minor version.
19
20
21
22
23
24
25

    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.
lizhigong's avatar
lizhigong committed
26
    """
27
28
29
30
31
    # 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!
lizhigong's avatar
lizhigong committed
32
    assert __version_tuple__[0] == 0
33
    assert isinstance(__version_tuple__[1], int)
34
    return version_str == f"{__version_tuple__[0]}.{__version_tuple__[1] - 1}"
35
36
37


def _prev_minor_version():
lizhigong's avatar
lizhigong committed
38
    """For the purpose of testing, return a previous minor version number."""
39
40
41
    # In dev tree, this will return "0.-1", but that will work fine"
    assert isinstance(__version_tuple__[1], int)
    return f"{__version_tuple__[0]}.{__version_tuple__[1] - 1}"