Skip to content

Commit 627163e

Browse files
rparolinclaude
andcommitted
Place cython-test .so in tests/cython regardless of cwd
tests/cython/build_tests.py runs `build_ext --inplace`, which writes the compiled .so relative to the current working directory. pixi runs the build-cython-tests task from the project root, so the .so landed in the package root instead of tests/cython/, where pytest imports it by bare module name. The test only passed previously because a correctly-placed .so from an earlier build persisted (gitignored); a clean checkout fails with ModuleNotFoundError. chdir to the script directory before build_ext --inplace so the .so lands next to its .pyx in both cuda_bindings and cuda_core (kept aligned per #1978). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 5d194cf commit 627163e

2 files changed

Lines changed: 16 additions & 0 deletions

File tree

cuda_bindings/tests/cython/build_tests.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from __future__ import annotations
1414

15+
import os
1516
import sys
1617
from pathlib import Path
1718

@@ -45,6 +46,13 @@ def main() -> None:
4546
compiler_directives={"freethreading_compatible": True},
4647
)
4748

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)
4856
sys.argv = [sys.argv[0], "build_ext", "--inplace"]
4957
setup(name="cuda_bindings_cython_tests", ext_modules=ext_modules)
5058

cuda_core/tests/cython/build_tests.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
from __future__ import annotations
1414

15+
import os
1516
import sys
1617
from pathlib import Path
1718

@@ -44,6 +45,13 @@ def main() -> None:
4445
compiler_directives={"freethreading_compatible": True},
4546
)
4647

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

0 commit comments

Comments
 (0)