|
12 | 12 | from pathlib import Path |
13 | 13 |
|
14 | 14 | from setuptools import setup |
| 15 | +from setuptools_scm import get_version |
15 | 16 |
|
16 | 17 |
|
17 | 18 | def uninstall_onnxruntime() -> None: |
@@ -104,6 +105,58 @@ def detect_target_device() -> str: |
104 | 105 | return "cuda" |
105 | 106 |
|
106 | 107 |
|
| 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 | + |
107 | 160 | def load_requirements(file_path: Path) -> list[str]: |
108 | 161 | """ |
109 | 162 | Load requirements from a file, supporting -r directive for recursive loading. |
@@ -167,5 +220,6 @@ def get_install_requires() -> list[str]: |
167 | 220 |
|
168 | 221 | # Setup configuration |
169 | 222 | setup( |
| 223 | + version=get_vllm_omni_version(), |
170 | 224 | install_requires=install_requires, |
171 | 225 | ) |
0 commit comments