Skip to content

build: add torch to build-system.requires#30

Open
rebel-junamsong wants to merge 1 commit intotatsy:masterfrom
rebel-junamsong:build/torch-build-dep
Open

build: add torch to build-system.requires#30
rebel-junamsong wants to merge 1 commit intotatsy:masterfrom
rebel-junamsong:build/torch-build-dep

Conversation

@rebel-junamsong
Copy link
Copy Markdown

Problem

`CMakeLists.txt` calls `find_package(Torch CONFIG REQUIRED)`, which searches for `TorchConfig.cmake` that ships inside the installed PyTorch Python package (`/torch/share/cmake/Torch/TorchConfig.cmake`). However, `torch` is not declared in `[build-system].requires`, so pip/uv's isolated build environment never has torch installed, causing the CMake configuration step to fail in any clean environment:

```
CMake Error at CMakeLists.txt:43 (find_package):
Could not find a package configuration file provided by "Torch" with any of
the following names:

TorchConfig.cmake
torch-config.cmake

```

Users currently have to either disable build isolation (`--no-build-isolation` plus pre-installing torch in the target env) or install from a working local checkout, rather than the simple `pip install git+https://github.com/tatsy/torchmcubes.git\`.

Fix

Minimal change: add `torch` to the existing `[build-system].requires` list. `cmake` and `ninja` are left untouched to stay consistent with the current project style.

```diff
[build-system]
-requires = ["scikit-build-core>=0.10", "pybind11>=2.10", "cmake", "ninja"]
+requires = ["scikit-build-core>=0.10", "pybind11>=2.10", "cmake", "ninja", "torch"]
```

Verification

After this change, `pip install git+https://github.com/tatsy/torchmcubes.git\` succeeds in a clean venv without any external workaround (no `--no-build-isolation`, no manually prepended `CMAKE_PREFIX_PATH`).

scikit-build-core's isolated build env runs CMakeLists.txt which calls
find_package(Torch CONFIG REQUIRED). The Torch CMake package ships
inside the installed PyTorch Python package (torch/share/cmake/Torch/
TorchConfig.cmake), so torch must be importable in the build env.

Without listing torch in [build-system].requires, any clean
`pip install git+https://github.com/tatsy/torchmcubes.git` fails with

  CMake Error at CMakeLists.txt:43 (find_package):
    Could not find a package configuration file provided by "Torch"

Adding torch here makes the install work in isolated build environments
without requiring --no-build-isolation or manually pre-installing torch.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant