From 21dce80ea96bcf033d159c0f952fb274567b315c Mon Sep 17 00:00:00 2001 From: Michael Goin Date: Tue, 19 Aug 2025 16:49:34 -0400 Subject: [PATCH] [CI/Build] Add support for Python 3.13 (#13164) Signed-off-by: mgoin Signed-off-by: mgoin Co-authored-by: Cyrus Leung --- CMakeLists.txt | 2 +- docs/getting_started/quickstart.md | 2 +- pyproject.toml | 3 ++- vllm/config/__init__.py | 12 +++++++++++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 34386d670ac7..bcbd1b52a06c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,7 @@ install(CODE "set(CMAKE_INSTALL_LOCAL_ONLY TRUE)" ALL_COMPONENTS) # Supported python versions. These versions will be searched in order, the # first match will be selected. These should be kept in sync with setup.py. # -set(PYTHON_SUPPORTED_VERSIONS "3.9" "3.10" "3.11" "3.12") +set(PYTHON_SUPPORTED_VERSIONS "3.9" "3.10" "3.11" "3.12", "3.13") # Supported AMD GPU architectures. set(HIP_SUPPORTED_ARCHS "gfx906;gfx908;gfx90a;gfx942;gfx950;gfx1030;gfx1100;gfx1101;gfx1200;gfx1201") diff --git a/docs/getting_started/quickstart.md b/docs/getting_started/quickstart.md index f83380766646..2af26626d207 100644 --- a/docs/getting_started/quickstart.md +++ b/docs/getting_started/quickstart.md @@ -8,7 +8,7 @@ This guide will help you quickly get started with vLLM to perform: ## Prerequisites - OS: Linux -- Python: 3.9 -- 3.12 +- Python: 3.9 -- 3.13 ## Installation diff --git a/pyproject.toml b/pyproject.toml index 03a32ac0ba3d..013f2a6cd59e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -24,13 +24,14 @@ classifiers = [ "Programming Language :: Python :: 3.10", "Programming Language :: Python :: 3.11", "Programming Language :: Python :: 3.12", + "Programming Language :: Python :: 3.13", "Intended Audience :: Developers", "Intended Audience :: Information Technology", "Intended Audience :: Science/Research", "Topic :: Scientific/Engineering :: Artificial Intelligence", "Topic :: Scientific/Engineering :: Information Analysis", ] -requires-python = ">=3.9,<3.13" +requires-python = ">=3.9,<3.14" dynamic = [ "version", "dependencies", "optional-dependencies"] [project.urls] diff --git a/vllm/config/__init__.py b/vllm/config/__init__.py index cd2be212c23d..56a749789b6a 100644 --- a/vllm/config/__init__.py +++ b/vllm/config/__init__.py @@ -191,7 +191,17 @@ def get_attr_docs(cls: type[Any]) -> dict[str, str]: yield a, b a = b - cls_node = ast.parse(textwrap.dedent(inspect.getsource(cls))).body[0] + try: + cls_node = ast.parse(textwrap.dedent(inspect.getsource(cls))).body[0] + except (OSError, KeyError, TypeError): + # HACK: Python 3.13+ workaround - set missing __firstlineno__ + # Workaround can be removed after we upgrade to pydantic==2.12.0 + with open(inspect.getfile(cls)) as f: + for i, line in enumerate(f): + if f"class {cls.__name__}" in line and ":" in line: + cls.__firstlineno__ = i + 1 + break + cls_node = ast.parse(textwrap.dedent(inspect.getsource(cls))).body[0] if not isinstance(cls_node, ast.ClassDef): raise TypeError("Given object was not a class.")