diff --git a/.gitignore b/.gitignore index f7b771bc73..cf3390782f 100644 --- a/.gitignore +++ b/.gitignore @@ -233,3 +233,6 @@ configs/development.yaml Dockerfile.dev discussion tmp_test + +# Auto-generated version file (created by setuptools_scm during build) +vllm_omni/_version.py diff --git a/pyproject.toml b/pyproject.toml index 706d0152e1..8e9f9bf8b6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -8,7 +8,7 @@ build-backend = "setuptools.build_meta" [project] name = "vllm-omni" -version = "0.14.0" +dynamic = ["version", "dependencies"] description = "A framework for efficient model inference with omni-modality models" readme = "README.md" requires-python = ">=3.10,<3.14" @@ -17,7 +17,6 @@ authors = [ {name = "vLLM-Omni Team"} ] keywords = ["vllm", "multimodal", "diffusion", "transformer", "inference", "serving"] -dynamic = ["dependencies"] classifiers = [ "Development Status :: 3 - Alpha", "Intended Audience :: Developers", @@ -85,6 +84,10 @@ include = ["vllm_omni*"] [tool.setuptools.package-data] "vllm_omni.model_executor.stage_configs" = ["*.yaml"] +[tool.setuptools_scm] +# Enable setuptools_scm for automatic version generation from git tags. +# Version is written to vllm_omni/_version.py during build. + [tool.ruff] line-length = 120 exclude = [ diff --git a/setup.py b/setup.py index e33c848a3f..496b032639 100644 --- a/setup.py +++ b/setup.py @@ -12,6 +12,7 @@ from pathlib import Path from setuptools import setup +from setuptools_scm import get_version def uninstall_onnxruntime() -> None: @@ -104,6 +105,71 @@ def detect_target_device() -> str: return "cuda" +def get_vllm_omni_version() -> str: + """ + Get the vLLM-Omni version with device-specific suffix. + + Version format: {base_version}+{device} + Examples: + - 0.14.0+cuda (release version with CUDA) + - 0.14.1.dev23+g1a2b3c4.rocm (dev version with ROCm) + - 0.15.0+npu (release version with NPU) + + Environment variables: + VLLM_OMNI_VERSION_OVERRIDE: Override version completely + VLLM_OMNI_TARGET_DEVICE: Override device detection + + Returns: + Version string with device suffix + """ + # Allow complete version override via environment variable + if env_version := os.getenv("VLLM_OMNI_VERSION_OVERRIDE"): + print(f"Overriding vLLM-Omni version with {env_version} from VLLM_OMNI_VERSION_OVERRIDE") + os.environ["SETUPTOOLS_SCM_PRETEND_VERSION"] = env_version + # Get version without device suffix for override case + version = get_version() + else: + # Generate version from git tags via setuptools_scm (without writing yet) + try: + version = get_version() + except Exception as e: + print(f"Warning: Failed to get version from git, using fallback: {e}") + version = "dev" + + # Determine separator: '+' for normal versions, '.' for dev versions with '+' + sep = "+" if "+" not in version else "." + + # Append device-specific suffix + device = detect_target_device() + + if device == "cuda": + version += f"{sep}cuda" + elif device == "rocm": + version += f"{sep}rocm" + elif device == "npu": + version += f"{sep}npu" + elif device == "xpu": + version += f"{sep}xpu" + elif device == "cpu": + version += f"{sep}cpu" + else: + raise RuntimeError(f"Unknown target device: {device}") + + # Write the FULL version (with device suffix) to _version.py + # This ensures runtime import matches the package metadata version + version_file = Path(__file__).parent / "vllm_omni" / "_version.py" + version_file.parent.mkdir(parents=True, exist_ok=True) + + with open(version_file, "w") as f: + f.write(f"""# Automatically generated by setuptools_scm +__version__ = {version!r} +__version_tuple__ = tuple(__version__.split('.')) +""") + + print(f"Generated version: {version}") + return version + + def load_requirements(file_path: Path) -> list[str]: """ Load requirements from a file, supporting -r directive for recursive loading. @@ -167,5 +233,6 @@ def get_install_requires() -> list[str]: # Setup configuration setup( + version=get_vllm_omni_version(), install_requires=install_requires, ) diff --git a/vllm_omni/version.py b/vllm_omni/version.py index 15253fe6fd..e5f0b6b661 100644 --- a/vllm_omni/version.py +++ b/vllm_omni/version.py @@ -1,3 +1,25 @@ -__version__ = "0.14.0" -__version_tuple__ = (0, 14, 0) -# TODO: add auto version generation +""" +Version information for vLLM-Omni. + +The version is automatically generated from git tags via setuptools_scm +and written to _version.py during package build. +""" + +try: + # Import auto-generated version from _version.py (created by setuptools_scm) + from ._version import __version__, __version_tuple__ +except ImportError as e: + import warnings + + warnings.warn( + f"Failed to import version from _version.py: {e}\n" + "This typically happens in development mode before building.\n" + "Using fallback version 'dev'.", + RuntimeWarning, + stacklevel=2, + ) + + __version__ = "dev" + __version_tuple__ = (0, 0, "dev") + +__all__ = ["__version__", "__version_tuple__"]