forked from vllm-project/vllm-gaudi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
46 lines (38 loc) · 1.38 KB
/
Copy pathmain.py
File metadata and controls
46 lines (38 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
"""mkdocs-macros hook – automatically sets {{ VLLM_VERSION }}.
The macros plugin loads this file and calls define_env() at startup.
VLLM_VERSION is derived from the latest git tag (e.g. v0.19.0 → 0.19.0).
Falls back to the branch name if it matches releases/vX.Y.Z.
"""
import re
import subprocess
def _get_vllm_version() -> str | None:
"""Extract version from the most recent vX.Y.Z git tag or branch name."""
try:
# Try the nearest release tag first
tag = subprocess.check_output(
["git", "describe", "--tags", "--abbrev=0", "--match", "v[0-9]*"],
stderr=subprocess.DEVNULL,
text=True,
).strip()
m = re.match(r"v?(\d+\.\d+\.\d+)", tag)
if m:
return m.group(1)
except (subprocess.CalledProcessError, FileNotFoundError):
pass
# Fallback: parse from branch name (e.g. releases/v0.19.0)
try:
branch = subprocess.check_output(
["git", "rev-parse", "--abbrev-ref", "HEAD"],
stderr=subprocess.DEVNULL,
text=True,
).strip()
m = re.match(r"releases/v?(\d+\.\d+\.\d+)", branch)
if m:
return m.group(1)
except (subprocess.CalledProcessError, FileNotFoundError):
pass
return None
def define_env(env):
version = _get_vllm_version()
if version:
env.variables["VLLM_VERSION"] = version