This issue was found by a Codex global scan of the repository at commit 19f9265.
pyproject.toml configures scikit-build to build the Python interface only:
|
[tool.scikit-build.cmake.define] |
|
BUILD_PY_IF = true |
|
BUILD_CPP_IF = false |
However, the CMake logic that queries torch.utils.cmake_prefix_path only runs for selected C++ builds or CIBUILDWHEEL=1:
|
if(BUILD_CPP_IF |
|
AND USE_PT_PYTHON_LIBS |
|
AND NOT CMAKE_CROSSCOMPILING |
|
AND NOT SKBUILD |
|
OR "$ENV{CIBUILDWHEEL}" STREQUAL "1") |
|
find_package( |
|
Python |
|
COMPONENTS Interpreter |
|
REQUIRED) |
|
execute_process( |
|
COMMAND ${Python_EXECUTABLE} -c |
|
"import torch;print(torch.utils.cmake_prefix_path)" |
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} |
|
OUTPUT_VARIABLE PYTORCH_CMAKE_PREFIX_PATH |
|
RESULT_VARIABLE PYTORCH_CMAKE_PREFIX_PATH_RESULT_VAR |
|
ERROR_VARIABLE PYTORCH_CMAKE_PREFIX_PATH_ERROR_VAR |
|
OUTPUT_STRIP_TRAILING_WHITESPACE) |
|
if(NOT ${PYTORCH_CMAKE_PREFIX_PATH_RESULT_VAR} EQUAL 0) |
|
message( |
|
FATAL_ERROR |
|
"Cannot determine PyTorch CMake prefix path, error code: $PYTORCH_CMAKE_PREFIX_PATH_RESULT_VAR}, error message: ${PYTORCH_CMAKE_PREFIX_PATH_ERROR_VAR}" |
|
) |
|
endif() |
|
list(APPEND CMAKE_PREFIX_PATH ${PYTORCH_CMAKE_PREFIX_PATH}) |
|
endif() |
find_package(Torch REQUIRED) then runs unconditionally:
|
find_package(Torch REQUIRED) |
|
if(Torch_VERSION VERSION_LESS "2.10.0") |
|
message(FATAL_ERROR "deepmd-gnn OP requires PyTorch >= 2.10.0 for the " |
|
"LibTorch Stable ABI.") |
|
endif() |
A normal local configure without user-supplied CMAKE_PREFIX_PATH fails with:
Could not find a package configuration file provided by "Torch"
Suggested fix: when BUILD_PY_IF is true and Torch_DIR/CMAKE_PREFIX_PATH is not already sufficient, query torch.utils.cmake_prefix_path using the build Python interpreter before find_package(Torch REQUIRED).
This issue was found by a Codex global scan of the repository at commit 19f9265.
pyproject.tomlconfigures scikit-build to build the Python interface only:deepmd-gnn/pyproject.toml
Lines 97 to 99 in 19f9265
However, the CMake logic that queries
torch.utils.cmake_prefix_pathonly runs for selected C++ builds orCIBUILDWHEEL=1:deepmd-gnn/CMakeLists.txt
Lines 85 to 109 in 19f9265
find_package(Torch REQUIRED)then runs unconditionally:deepmd-gnn/CMakeLists.txt
Lines 120 to 124 in 19f9265
A normal local configure without user-supplied
CMAKE_PREFIX_PATHfails with:Suggested fix: when
BUILD_PY_IFis true andTorch_DIR/CMAKE_PREFIX_PATHis not already sufficient, querytorch.utils.cmake_prefix_pathusing the build Python interpreter beforefind_package(Torch REQUIRED).