Skip to content

Commit c779d43

Browse files
committed
auto generate version using setuptool_scm
Signed-off-by: tjtanaa <tunjian.tan@embeddedllm.com>
1 parent 78a5aae commit c779d43

File tree

4 files changed

+87
-5
lines changed

4 files changed

+87
-5
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,3 +233,6 @@ configs/development.yaml
233233
Dockerfile.dev
234234
discussion
235235
tmp_test
236+
237+
# Auto-generated version file (created by setuptools_scm during build)
238+
vllm_omni/_version.py

pyproject.toml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta"
88

99
[project]
1010
name = "vllm-omni"
11-
version = "0.14.0"
11+
dynamic = ["version", "dependencies"]
1212
description = "A framework for efficient model inference with omni-modality models"
1313
readme = "README.md"
1414
requires-python = ">=3.10,<3.14"
@@ -17,7 +17,6 @@ authors = [
1717
{name = "vLLM-Omni Team"}
1818
]
1919
keywords = ["vllm", "multimodal", "diffusion", "transformer", "inference", "serving"]
20-
dynamic = ["dependencies"]
2120
classifiers = [
2221
"Development Status :: 3 - Alpha",
2322
"Intended Audience :: Developers",
@@ -85,6 +84,10 @@ include = ["vllm_omni*"]
8584
[tool.setuptools.package-data]
8685
"vllm_omni.model_executor.stage_configs" = ["*.yaml"]
8786

87+
[tool.setuptools_scm]
88+
# Enable setuptools_scm for automatic version generation from git tags.
89+
# Version is written to vllm_omni/_version.py during build.
90+
8891
[tool.ruff]
8992
line-length = 120
9093
exclude = [

setup.py

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from pathlib import Path
1313

1414
from setuptools import setup
15+
from setuptools_scm import get_version
1516

1617

1718
def uninstall_onnxruntime() -> None:
@@ -104,6 +105,58 @@ def detect_target_device() -> str:
104105
return "cuda"
105106

106107

108+
def get_vllm_omni_version() -> str:
109+
"""
110+
Get the vLLM-Omni version with device-specific suffix.
111+
112+
Version format: {base_version}+{device}
113+
Examples:
114+
- 0.14.0+cuda (release version with CUDA)
115+
- 0.14.1.dev23+g1a2b3c4+rocm (dev version with ROCm)
116+
- 0.15.0+npu (release version with NPU)
117+
118+
Environment variables:
119+
VLLM_OMNI_VERSION_OVERRIDE: Override version completely
120+
VLLM_OMNI_TARGET_DEVICE: Override device detection
121+
122+
Returns:
123+
Version string with device suffix
124+
"""
125+
# Allow complete version override via environment variable
126+
if env_version := os.getenv("VLLM_OMNI_VERSION_OVERRIDE"):
127+
print(f"Overriding vLLM-Omni version with {env_version} from VLLM_OMNI_VERSION_OVERRIDE")
128+
os.environ["SETUPTOOLS_SCM_PRETEND_VERSION"] = env_version
129+
return get_version(write_to="vllm_omni/_version.py")
130+
131+
# Generate version from git tags via setuptools_scm
132+
try:
133+
version = get_version(write_to="vllm_omni/_version.py")
134+
except Exception as e:
135+
print(f"Warning: Failed to get version from git, using fallback: {e}")
136+
version = "dev"
137+
138+
# Determine separator: '+' for normal versions, '.' for dev versions with '+'
139+
sep = "+" if "+" not in version else "."
140+
141+
# Append device-specific suffix
142+
device = detect_target_device()
143+
144+
if device == "cuda":
145+
version += f"{sep}cuda"
146+
elif device == "rocm":
147+
version += f"{sep}rocm"
148+
elif device == "npu":
149+
version += f"{sep}npu"
150+
elif device == "xpu":
151+
version += f"{sep}xpu"
152+
elif device == "cpu":
153+
version += f"{sep}cpu"
154+
else:
155+
raise RuntimeError(f"Unknown target device: {device}")
156+
157+
return version
158+
159+
107160
def load_requirements(file_path: Path) -> list[str]:
108161
"""
109162
Load requirements from a file, supporting -r directive for recursive loading.
@@ -167,5 +220,6 @@ def get_install_requires() -> list[str]:
167220

168221
# Setup configuration
169222
setup(
223+
version=get_vllm_omni_version(),
170224
install_requires=install_requires,
171225
)

vllm_omni/version.py

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1-
__version__ = "0.14.0"
2-
__version_tuple__ = (0, 14, 0)
3-
# TODO: add auto version generation
1+
"""
2+
Version information for vLLM-Omni.
3+
4+
The version is automatically generated from git tags via setuptools_scm
5+
and written to _version.py during package build.
6+
"""
7+
8+
try:
9+
# Import auto-generated version from _version.py (created by setuptools_scm)
10+
from ._version import __version__, __version_tuple__
11+
except ImportError as e:
12+
import warnings
13+
14+
warnings.warn(
15+
f"Failed to import version from _version.py: {e}\n"
16+
"This typically happens in development mode before building.\n"
17+
"Using fallback version 'dev'.",
18+
RuntimeWarning,
19+
stacklevel=2,
20+
)
21+
22+
__version__ = "dev"
23+
__version_tuple__ = (0, 0, "dev")
24+
25+
__all__ = ["__version__", "__version_tuple__"]

0 commit comments

Comments
 (0)