| 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | # SPDX-FileCopyrightText: Copyright contributors to the vLLM project |
| 3 | import os |
| 4 | from collections.abc import Iterable |
| 5 | from pathlib import Path |
| 6 | |
| 7 | import pytest |
| 8 | |
| 9 | from vllm.platforms import current_platform |
| 10 | |
| 11 | |
| 12 | @pytest.fixture |
| 13 | def rocm_sitecustomize_factory(monkeypatch, tmp_path: Path): |
| 14 | """Return a function that installs a given sitecustomize payload.""" |
| 15 | if not current_platform.is_rocm(): |
| 16 | return lambda _: None |
| 17 | |
| 18 | def install(lines: Iterable[str]) -> None: |
| 19 | sc = tmp_path / "sitecustomize.py" |
| 20 | sc.write_text("\n".join(lines) + "\n") |
| 21 | monkeypatch.setenv( |
| 22 | "PYTHONPATH", |
| 23 | os.pathsep.join(filter(None, [str(tmp_path), os.getenv("PYTHONPATH")])), |
| 24 | ) |
| 25 | |
| 26 | return install |