[Misc] Allow install empty package from pip (#41074)

Signed-off-by: wangxiyuan <wangxiyuan1007@gmail.com>
This commit is contained in:
wangxiyuan
2026-09-16 02:02:37 +00:00
committed by GitHub
parent a4d2d9d95e
commit b0898a4937
2 changed files with 37 additions and 28 deletions
+32 -28
View File
@@ -1257,35 +1257,39 @@ def get_vllm_version() -> str:
version = get_version(write_to="vllm/_version.py")
sep = "+" if "+" not in version else "." # dev versions might contain +
if _no_device():
if envs.VLLM_TARGET_DEVICE == "empty":
version += f"{sep}empty"
elif _is_cuda():
if USE_PRECOMPILED_EXTENSIONS and not envs.VLLM_SKIP_PRECOMPILED_VERSION_SUFFIX:
version += f"{sep}precompiled"
if not envs.VLLM_SKIP_VERSION_SUFFIX:
if _no_device():
if envs.VLLM_TARGET_DEVICE == "empty":
version += f"{sep}empty"
elif _is_cuda():
if (
USE_PRECOMPILED_EXTENSIONS
and not envs.VLLM_SKIP_PRECOMPILED_VERSION_SUFFIX
):
version += f"{sep}precompiled"
else:
cuda_version = str(get_nvcc_cuda_version())
if cuda_version != envs.VLLM_MAIN_CUDA_VERSION:
cuda_version_str = cuda_version.replace(".", "")[:3]
# skip this for source tarball, required for pypi
if "sdist" not in sys.argv:
version += f"{sep}cu{cuda_version_str}"
elif _is_hip():
# Get the Rocm Version
rocm_version = get_rocm_version() or torch.version.hip
if rocm_version and rocm_version != envs.VLLM_MAIN_CUDA_VERSION:
version += f"{sep}rocm{rocm_version.replace('.', '')[:3]}"
elif _is_tpu():
version += f"{sep}tpu"
elif _is_cpu():
# Check the local VLLM_TARGET_DEVICE (may be set by auto-detect above),
# not envs.VLLM_TARGET_DEVICE, so CPU-only hosts still get `+cpu`.
if VLLM_TARGET_DEVICE == "cpu":
version += f"{sep}cpu"
elif _is_xpu():
version += f"{sep}xpu"
else:
cuda_version = str(get_nvcc_cuda_version())
if cuda_version != envs.VLLM_MAIN_CUDA_VERSION:
cuda_version_str = cuda_version.replace(".", "")[:3]
# skip this for source tarball, required for pypi
if "sdist" not in sys.argv:
version += f"{sep}cu{cuda_version_str}"
elif _is_hip():
# Get the Rocm Version
rocm_version = get_rocm_version() or torch.version.hip
if rocm_version and rocm_version != envs.VLLM_MAIN_CUDA_VERSION:
version += f"{sep}rocm{rocm_version.replace('.', '')[:3]}"
elif _is_tpu():
version += f"{sep}tpu"
elif _is_cpu():
# Check the local VLLM_TARGET_DEVICE (may be set by auto-detect above),
# not envs.VLLM_TARGET_DEVICE, so CPU-only hosts still get `+cpu`.
if VLLM_TARGET_DEVICE == "cpu":
version += f"{sep}cpu"
elif _is_xpu():
version += f"{sep}xpu"
else:
raise RuntimeError("Unknown runtime environment")
raise RuntimeError("Unknown runtime environment")
return version
+5
View File
@@ -2176,6 +2176,10 @@ environment_variables: dict[str, Callable[[], Any]] = {
# Each op additionally checks its own shape / dtype constraints and falls
# back to the eager path when they do not hold.
"VLLM_ENABLE_HPC_OPS": lambda: bool(int(os.getenv("VLLM_ENABLE_HPC_OPS", "0"))),
# Whether to skip version suffix when building package
"VLLM_SKIP_VERSION_SUFFIX": lambda: bool(
int(os.getenv("VLLM_SKIP_VERSION_SUFFIX", "0"))
),
}
@@ -2344,6 +2348,7 @@ def compile_factors() -> dict[str, object]:
"LOCAL_RANK",
"CUDA_VISIBLE_DEVICES",
"NO_COLOR",
"VLLM_SKIP_VERSION_SUFFIX",
}
from vllm.config.utils import normalize_value