Repository navigation
Conversation
setup.py imports torch.utils.cpp_extension at module scope, so torch has to be in the build environment too. Without a pyproject.toml pip falls back to the PEP 517 defaults and isolates the build with only setuptools + wheel, so 'getting requirements to build wheel' dies with ModuleNotFoundError: No module named 'torch'. Declare setuptools>=64, wheel and torch as build requirements and use the setuptools.build_meta backend. Package metadata stays in setup.py as the single source of truth so no version or dependency pin changes. Signed-off-by: u7-u7 <116776533+u7-u7@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Refs #5.
Problem
With no
pyproject.toml, a PEP 517 frontend cannot read this project's metadata at all in a clean environment — the failure happens before anything CUDA-related is even reached:Root cause
setup.py:18importstorch.utils.cpp_extensionat module scope to describe the CUDA extension, so torch must be present in the build environment, not only in the runtime environment. Withoutpyproject.tomlpip falls back to the PEP 517 defaults: a build-isolated environment containing onlysetuptools+wheel. The backend therefore cannot importsetup.pyeven to generate metadata. The only workaround today is--no-build-isolation, which nothing in the repository tells a user to pass (README'sBuild & Testsection just sayspip install -e .).Fix
One new file, no existing file touched:
setuptools>=64is what provides the PEP 660 editable-install path;torchis the importsetup.pyactually needs (wheelis kept alongside for older builders).Deliberately not included:
[project]table.pyproject.tomlmetadata takes precedence over the equivalentsetup()arguments, so duplicating name/version/install_requireshere would create two sources of truth (a version bump would have to be made twice). They stay insetup.py.nvidia-cutlass-dsl==4.6.2pin and the absence of a runtime torch pin are untouched, and the build requirement carries no invented version floor either.Verification
Machine: macOS arm64, no NVIDIA GPU and no
nvcc, so the compile step itself cannot run here. The verification is therefore split in two: the real repo before/after, plus a packaging-only experiment that removes CUDA from the equation entirely.Environment for every command below:
python -m venvon CPython 3.12.12, pip 25.0.1, fresh venv without torch.1. Real repo, before (pristine
mastercheckout)2. Real repo, after (this branch)
torchis now resolved into the isolated build environment,import torchsucceeds, and the only remaining failure is the pre-existing CUDA toolchain prerequisite (CUDA_HOME/nvcc), which is a property of this GPU-less machine, not of the packaging.3. Packaging-only experiment (isolates packaging from the CUDA toolchain)
To show the
pyproject.tomlis sufficient rather than a partial improvement, I copied the repo into two throwaway directories (/tmp, no repository file modified), stubbedext_modulesto[]in both copies so nothing CUDA is ever constructed, and ran the same command on each — one copy withoutpyproject.toml, one with this branch's file:Same
setup.py, same interpreter, same network: the single added file is what turns a hard metadata failure into a working build/environment resolution.4. Existing test suite
tests/requires multiple GPUs with NVLink (see README, Build & Test), so none of it can run on this machine. This patch adds a packaging file and touches no Python or kernel code path, so those results are unaffected — but I did not run them and am not claiming to have.Risk / compatibility
pip install ./pip install -e .now work under build isolation by default (previously they could not). A contributor who would rather build the extension against the torch already installed in their environment — e.g. to match the runtime ABI exactly — can keep doing that withpip install --no-build-isolation -e .; that path is unchanged.AI assistance: this patch was prepared with AI assistance; I reproduced the bug and verified the fix with the commands above.