Skip to content

Commit fc4467d

Browse files
authored
Fix Windows Cython test build paths (#2650)
Run the Python build driver from the batch wrapper and feed Cython relative source names after switching to the tests/cython directory. This avoids duplicating the absolute checkout path under build/temp and preserves the build result.
1 parent 0b5d816 commit fc4467d

2 files changed

Lines changed: 12 additions & 12 deletions

File tree

cuda_bindings/tests/cython/build_tests.bat

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@ REM SPDX-FileCopyrightText: Copyright (c) 2024-2026 NVIDIA CORPORATION & AFFILIA
44
REM SPDX-License-Identifier: Apache-2.0
55

66
setlocal
7-
set CL=%CL% /I"%CUDA_HOME%\include"
8-
REM Use -j 1 to side-step any process-pool issues and ensure deterministic single-threaded builds
9-
cythonize -3 -j 1 -i -Xfreethreading_compatible=True %~dp0test_*.pyx
10-
endlocal
7+
set CL=%CL% /I"%CUDA_HOME%\include"
8+
REM The Python driver provides Cython's .pxd include path and builds in this
9+
REM directory so Windows does not duplicate the checkout path in link outputs.
10+
python "%~dp0build_tests.py"
11+
set "BUILD_RESULT=%ERRORLEVEL%"
12+
endlocal & exit /b %BUILD_RESULT%

cuda_bindings/tests/cython/build_tests.py

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ def _bindings_source_root() -> Path:
3434

3535
def main() -> None:
3636
script_dir = Path(__file__).resolve().parent
37-
pyx_files = sorted(str(p) for p in script_dir.glob("test_*.pyx"))
37+
# Avoid appending the absolute checkout path under build/temp: the
38+
# concatenated path can exceed Windows' path limit. These files are siblings.
39+
os.chdir(script_dir)
40+
pyx_files = sorted(p.name for p in script_dir.glob("test_*.pyx"))
3841
if not pyx_files:
3942
raise SystemExit(f"no test_*.pyx files under {script_dir}")
4043

@@ -46,13 +49,8 @@ def main() -> None:
4649
compiler_directives={"freethreading_compatible": True},
4750
)
4851

49-
# `build_ext --inplace` places the compiled .so relative to the current
50-
# working directory, but pixi runs this task from the project root. pytest
51-
# imports each extension by bare module name (see test_cython.py), which
52-
# only resolves when the .so sits in tests/cython (the dir pytest puts on
53-
# sys.path). chdir here so the .so lands next to its .pyx regardless of the
54-
# invoking cwd.
55-
os.chdir(script_dir)
52+
# pytest imports each extension by bare module name (see test_cython.py),
53+
# so build in-place next to its .pyx regardless of the invoking cwd.
5654
sys.argv = [sys.argv[0], "build_ext", "--inplace"]
5755
setup(name="cuda_bindings_cython_tests", ext_modules=ext_modules)
5856

0 commit comments

Comments
 (0)