Skip to content

cuda.core: anchor _extension_depends() on build_hooks.py's location - #2870

Closed
Andy-Jost wants to merge 2 commits into
NVIDIA:mainfrom
Andy-Jost:ajost/build-hooks-depends-path
Closed

Andy-Jost wants to merge 2 commits into
NVIDIA:mainfrom
Andy-Jost:ajost/build-hooks-depends-path

Conversation

@Andy-Jost

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #2837: applies the review suggestion in #2837 (comment). _extension_depends() located the _cpp headers relative to the current directory; it now anchors on the location of build_hooks.py, so the depends list does not assume the process runs inside cuda_core.

The other relative paths in build_hooks.py (the .pyx glob, _extension_sources(), include_dirs) stay cwd-relative on purpose: cythonize mirrors the relative source path under build/, and the backend already converts absolute sources back to relative paths for that reason. PEP 517 frontends run the backend inside the project directory, so those hold under every supported build.

🤖 Generated with Claude Code

The depends list located the _cpp headers relative to the current
directory. Anchor it on the module's own path so it does not assume the
process runs inside cuda_core. Follow-up to a review comment on NVIDIA#2837.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@Andy-Jost Andy-Jost added this to the cuda.core 1.3.0 milestone Sep 15, 2026
@Andy-Jost Andy-Jost added P1 Medium priority - Should do CI/CD CI/CD infrastructure cuda.core Everything related to the cuda.core module labels Sep 15, 2026
@Andy-Jost Andy-Jost self-assigned this Sep 15, 2026
@Andy-Jost
Andy-Jost requested a review from mdboom September 15, 2026 22:58
@Andy-Jost

Copy link
Copy Markdown
Contributor Author

@mdboom Following up on your suggestion from #2837 (#2837 (comment)). Applying it as-is fails CI on every platform, and I want to understand your workflow before deciding how to proceed.

What breaks: tests/test_build_hooks.py::TestExtensionDepends pins _extension_depends() to cwd-relative paths (it chdirs into a temp tree), and the anchored version returns absolute paths from the real source tree instead. That test is easy to change, but the rest of the backend makes the same assumption: PEP 517 runs hooks with the working directory set to the source tree, _extension_sources() returns cwd-relative paths, setuptools resolves them against cwd, and cythonize's depends handling relpaths against os.getcwd() and skips the header copy when a file is not under it ("distutil extension depends are relative to cwd"). So anchoring depends alone would move the failure rather than remove it.

You mentioned the relative path breaks your workflow. How are you invoking the build when the current directory is not cuda_core? With that I can see which of these is the right shape:

  1. Abandon this PR, if your invocation can run from cuda_core (or through a PEP 517 frontend, which guarantees it).
  2. Anchor everything consistently on build_hooks.py's location, including sources and include dirs, and drop the relative-path assumption throughout.
  3. Something else you have in mind.

Happy to take whichever you think is right.

@mdboom

mdboom commented Sep 17, 2026

Copy link
Copy Markdown
Contributor

How are you invoking the build when the current directory is not cuda_core?

uv pip install -v ./cuda_bindings ./cuda_core

It looks like build isolation is taking care of making this work these days anyway, so perhaps this isn't needed after all.

@Andy-Jost

Copy link
Copy Markdown
Contributor Author

Thanks, that answers it. uv pip install ./cuda_core is a PEP 517 frontend invocation, and frontends always run the backend with the working directory set to the project directory, so the cwd-relative paths in build_hooks.py hold for that workflow. The anchored depends list was also the only absolute path in an otherwise cwd-relative backend, and it broke the Windows depends test for that reason. Closing as not needed; the suggestion thread on #2837 is resolved by the same reasoning.

@Andy-Jost Andy-Jost closed this Sep 17, 2026
@Andy-Jost
Andy-Jost deleted the ajost/build-hooks-depends-path branch September 17, 2026 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CI/CD CI/CD infrastructure cuda.core Everything related to the cuda.core module P1 Medium priority - Should do

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants