main
py 41 lines 1.44 KB
Raw
1 # SPDX-License-Identifier: Apache-2.0
2 # SPDX-FileCopyrightText: Copyright contributors to the vLLM project
3
4 """Assert the installed vLLM has a `_C.cpython-X.Y-*.so` for every CPython
5 covered by `requires-python`. Fails closed if a Python's `.so` is missing
6 from the wheel — i.e. the regression that surfaced in #41476/#41512.
7
8 Run from a CI test job after vLLM is installed, e.g. the H100 deepgemm
9 kernel tests in .buildkite/test_areas/kernels.yaml.
10 """
11
12 import importlib.util
13 import os
14 import sys
15 from pathlib import Path
16
17 import regex as re
18 import tomllib
19
20 SO_RE = re.compile(r"^_C\.cpython-(\d)(\d+)-")
21
22
23 def required_pythons() -> list[str]:
24 pyproject = Path(__file__).resolve().parent.parent / "pyproject.toml"
25 spec = tomllib.loads(pyproject.read_text())["project"]["requires-python"]
26 m = re.match(r">=3\.(\d+),<3\.(\d+)", spec)
27 if not m:
28 sys.exit(f"unexpected requires-python format: {spec!r}")
29 return [f"3.{v}" for v in range(int(m[1]), int(m[2]))]
30
31
32 spec = importlib.util.find_spec("vllm.third_party.deep_gemm")
33 if spec is None or spec.origin is None:
34 sys.exit("vllm.third_party.deep_gemm not importable; is vllm installed?")
35 pkg_dir = Path(spec.origin).parent
36
37 found = {f"{m[1]}.{m[2]}" for f in os.listdir(pkg_dir) if (m := SO_RE.match(f))}
38 required = required_pythons()
39 missing = [v for v in required if v not in found]
40 print(f"deepgemm _C: found {sorted(found)}, required {required}, missing {missing}")
41 sys.exit(1 if missing else 0)