| 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | # SPDX-FileCopyrightText: Copyright contributors to the vLLM project |
| 3 | |
| 4 | try: |
| 5 | from ._version import __version__, __version_tuple__ |
| 6 | except Exception as e: |
| 7 | import warnings |
| 8 | |
| 9 | warnings.warn(f"Failed to read commit hash:\n{e}", RuntimeWarning, stacklevel=2) |
| 10 | |
| 11 | __version__ = "dev" |
| 12 | __version_tuple__ = (0, 0, __version__) |
| 13 | |
| 14 | |
| 15 | def _prev_minor_version_was(version_str): |
| 16 | """Check whether a given version matches the previous minor version. |
| 17 | |
| 18 | Return True if version_str matches the previous minor version. |
| 19 | |
| 20 | For example - return True if the current version if 0.7.4 and the |
| 21 | supplied version_str is '0.6'. |
| 22 | |
| 23 | Used for --show-hidden-metrics-for-version. |
| 24 | """ |
| 25 | # Match anything if this is a dev tree |
| 26 | if __version_tuple__[0:2] == (0, 0): |
| 27 | return True |
| 28 | |
| 29 | assert isinstance(__version_tuple__[1], int) |
| 30 | return version_str == f"{__version_tuple__[0]}.{__version_tuple__[1] - 1}" |
| 31 | |
| 32 | |
| 33 | def _prev_minor_version(): |
| 34 | """For the purpose of testing, return a previous minor version number.""" |
| 35 | # In dev tree, this will return "0.-1", but that will work fine" |
| 36 | assert isinstance(__version_tuple__[1], int) |
| 37 | return f"{__version_tuple__[0]}.{__version_tuple__[1] - 1}" |