From ebe8fb489cc0c9d153a227732eeda10c3d9fa4e4 Mon Sep 17 00:00:00 2001 From: 0z5a Date: Wed, 4 Nov 2026 21:40:47 +0100 Subject: [PATCH] [bugfix] Fix Python-only kernel build default (#2064) --- fastvideo-kernel/build.sh | 2 +- fastvideo-kernel/tests/test_build_arch.py | 30 +++++++++++++++++++++-- 2 files changed, 29 insertions(+), 3 deletions(-) diff --git a/fastvideo-kernel/build.sh b/fastvideo-kernel/build.sh index 71745e10c..a0d6a6797 100755 --- a/fastvideo-kernel/build.sh +++ b/fastvideo-kernel/build.sh @@ -80,7 +80,7 @@ extension_mode_from_cmake_args() { && printf '%s' "${BASH_REMATCH[2]^^}" } if (( PYTHON_ONLY )); then - _explicit_mode="$(extension_mode_from_cmake_args)" + _explicit_mode="$(extension_mode_from_cmake_args || true)" if [[ -n "${_explicit_mode}" && "${_explicit_mode}" != "OFF" ]]; then echo "ERROR: --python-only conflicts with CMAKE_ARGS -DFASTVIDEO_KERNEL_BUILD_EXTENSION=${_explicit_mode}" >&2 exit 2 diff --git a/fastvideo-kernel/tests/test_build_arch.py b/fastvideo-kernel/tests/test_build_arch.py index 45a200709..14ca51adc 100644 --- a/fastvideo-kernel/tests/test_build_arch.py +++ b/fastvideo-kernel/tests/test_build_arch.py @@ -15,7 +15,11 @@ def _write_executable(path: Path, contents: str) -> None: def _run_build( - tmp_path: Path, capability: str, cuda_release: str, cmake_args: str | None = None + tmp_path: Path, + capability: str, + cuda_release: str, + cmake_args: str | None = None, + extra_args: list[str] | None = None, ) -> tuple[subprocess.CompletedProcess[str], Path]: kernel_dir = tmp_path / "fastvideo-kernel" kernel_dir.mkdir() @@ -51,7 +55,7 @@ def _run_build( if cmake_args is not None: env["CMAKE_ARGS"] = cmake_args result = subprocess.run( - ["bash", "build.sh"], + ["bash", "build.sh", *(extra_args or [])], cwd=kernel_dir, env=env, capture_output=True, @@ -103,3 +107,25 @@ def test_build_script_preserves_explicit_tk_option(tmp_path: Path, option: str) assert result.returncode == 0, result.stderr assert (result_dir / "cmake_args").read_text().count("-DFASTVIDEO_KERNEL_BUILD_TK=") == 1 assert f"-DFASTVIDEO_KERNEL_BUILD_TK={option}" in (result_dir / "cmake_args").read_text() + + +@pytest.mark.parametrize("cmake_args", [None, "-DOTHER_OPTION=ON", "-DFASTVIDEO_KERNEL_BUILD_EXTENSION=OFF"]) +@pytest.mark.parametrize("build_args", [["--python-only"], ["--rocm", "--python-only"]]) +def test_python_only_build_defaults_extension_to_off( + tmp_path: Path, cmake_args: str | None, build_args: list[str] +) -> None: + result, result_dir = _run_build(tmp_path, "9.0", "13.0", cmake_args, build_args) + + assert result.returncode == 0, result.stderr + assert (result_dir / "cmake_args").read_text().count("-DFASTVIDEO_KERNEL_BUILD_EXTENSION=OFF") == 1 + if cmake_args == "-DOTHER_OPTION=ON": + assert cmake_args in (result_dir / "cmake_args").read_text() + if "--rocm" in build_args: + assert "-DGPU_BACKEND=ROCM" in (result_dir / "cmake_args").read_text() + + +def test_python_only_build_rejects_extension_on(tmp_path: Path) -> None: + result, _ = _run_build(tmp_path, "9.0", "13.0", "-DFASTVIDEO_KERNEL_BUILD_EXTENSION=ON", ["--python-only"]) + + assert result.returncode != 0 + assert "--python-only conflicts" in result.stderr