[Misc] Allow install empty package from pip (#41074)
Signed-off-by: wangxiyuan <wangxiyuan1007@gmail.com>
wangxiyuan committed
Sep 16, 2026 at 10:02 UTC
b0898a493737ed34864efb2dbebc36a73ea043c5
2 files changed
+37
-28
setup.py
+32
-28
@@ -1257,35 +1257,39 @@ def get_vllm_version() -> str:
1257
version = get_version(write_to="vllm/_version.py")
1258
sep = "+" if "+" not in version else "." # dev versions might contain +
1259
1260
- if _no_device():
1261
- if envs.VLLM_TARGET_DEVICE == "empty":
1262
- version += f"{sep}empty"
1263
- elif _is_cuda():
1264
- if USE_PRECOMPILED_EXTENSIONS and not envs.VLLM_SKIP_PRECOMPILED_VERSION_SUFFIX:
1265
- version += f"{sep}precompiled"
1260
+ if not envs.VLLM_SKIP_VERSION_SUFFIX:
1261
+ if _no_device():
1262
+ if envs.VLLM_TARGET_DEVICE == "empty":
1263
+ version += f"{sep}empty"
1264
+ elif _is_cuda():
1265
+ if (
1266
+ USE_PRECOMPILED_EXTENSIONS
1267
+ and not envs.VLLM_SKIP_PRECOMPILED_VERSION_SUFFIX
1268
+ ):
1269
+ version += f"{sep}precompiled"
1270
+ else:
1271
+ cuda_version = str(get_nvcc_cuda_version())
1272
+ if cuda_version != envs.VLLM_MAIN_CUDA_VERSION:
1273
+ cuda_version_str = cuda_version.replace(".", "")[:3]
1274
+ # skip this for source tarball, required for pypi
1275
+ if "sdist" not in sys.argv:
1276
+ version += f"{sep}cu{cuda_version_str}"
1277
+ elif _is_hip():
1278
+ # Get the Rocm Version
1279
+ rocm_version = get_rocm_version() or torch.version.hip
1280
+ if rocm_version and rocm_version != envs.VLLM_MAIN_CUDA_VERSION:
1281
+ version += f"{sep}rocm{rocm_version.replace('.', '')[:3]}"
1282
+ elif _is_tpu():
1283
+ version += f"{sep}tpu"
1284
+ elif _is_cpu():
1285
+ # Check the local VLLM_TARGET_DEVICE (may be set by auto-detect above),
1286
+ # not envs.VLLM_TARGET_DEVICE, so CPU-only hosts still get `+cpu`.
1287
+ if VLLM_TARGET_DEVICE == "cpu":
1288
+ version += f"{sep}cpu"
1289
+ elif _is_xpu():
1290
+ version += f"{sep}xpu"
1291
else:
1267
- cuda_version = str(get_nvcc_cuda_version())
1268
- if cuda_version != envs.VLLM_MAIN_CUDA_VERSION:
1269
- cuda_version_str = cuda_version.replace(".", "")[:3]
1270
- # skip this for source tarball, required for pypi
1271
- if "sdist" not in sys.argv:
1272
- version += f"{sep}cu{cuda_version_str}"
1273
- elif _is_hip():
1274
- # Get the Rocm Version
1275
- rocm_version = get_rocm_version() or torch.version.hip
1276
- if rocm_version and rocm_version != envs.VLLM_MAIN_CUDA_VERSION:
1277
- version += f"{sep}rocm{rocm_version.replace('.', '')[:3]}"
1278
- elif _is_tpu():
1279
- version += f"{sep}tpu"
1280
- elif _is_cpu():
1281
- # Check the local VLLM_TARGET_DEVICE (may be set by auto-detect above),
1282
- # not envs.VLLM_TARGET_DEVICE, so CPU-only hosts still get `+cpu`.
1283
- if VLLM_TARGET_DEVICE == "cpu":
1284
- version += f"{sep}cpu"
1285
- elif _is_xpu():
1286
- version += f"{sep}xpu"
1287
- else:
1288
- raise RuntimeError("Unknown runtime environment")
1292
+ raise RuntimeError("Unknown runtime environment")
1293
1294
return version
1295
vllm/envs.py
+5
@@ -2176,6 +2176,10 @@ environment_variables: dict[str, Callable[[], Any]] = {
2176
# Each op additionally checks its own shape / dtype constraints and falls
2177
# back to the eager path when they do not hold.
2178
"VLLM_ENABLE_HPC_OPS": lambda: bool(int(os.getenv("VLLM_ENABLE_HPC_OPS", "0"))),
2179
+ # Whether to skip version suffix when building package
2180
+ "VLLM_SKIP_VERSION_SUFFIX": lambda: bool(
2181
+ int(os.getenv("VLLM_SKIP_VERSION_SUFFIX", "0"))
2182
+ ),
2183
}
2184
2185
@@ -2344,6 +2348,7 @@ def compile_factors() -> dict[str, object]:
2348
"LOCAL_RANK",
2349
"CUDA_VISIBLE_DEVICES",
2350
"NO_COLOR",
2351
+ "VLLM_SKIP_VERSION_SUFFIX",
2352
}
2353
2354
from vllm.config.utils import normalize_value