Repository navigation
[mlir][python] Fail fast when nanobind is missing for Python bindings - #174649
Merged
Merged
Conversation
Remove problematic `return()` statements from mlir_configure_python_dev_packages macro and convert nanobind detection to FATAL_ERROR. Using `return()` in a CMake macro is problematic because it returns from the calling scope, not the macro itself, causing the parent CMakeLists.txt to silently skip subsequent configuration steps. This leads to confusing build failures when Python bindings are enabled but nanobind is missing. With this change, users get an immediate error with clear instructions to install nanobind or set nanobind_DIR, rather than silent configuration failures.
Member
|
@llvm/pr-subscribers-mlir Author: Hideto Ueno (uenoku) ChangesRemove problematic Using With this change, users get an immediate error with clear instructions to install nanobind or set nanobind_DIR, rather than silent configuration failures. 1 Files Affected:
diff --git a/mlir/cmake/modules/MLIRDetectPythonEnv.cmake b/mlir/cmake/modules/MLIRDetectPythonEnv.cmake
index 098d12aedeb91..01dd7437cc8fc 100644
--- a/mlir/cmake/modules/MLIRDetectPythonEnv.cmake
+++ b/mlir/cmake/modules/MLIRDetectPythonEnv.cmake
@@ -60,8 +60,7 @@ macro(mlir_configure_python_dev_packages)
OUTPUT_VARIABLE PACKAGE_DIR
ERROR_QUIET)
if(NOT STATUS EQUAL "0")
- message(STATUS "not found (install via 'pip install nanobind' or set nanobind_DIR)")
- return()
+ message(FATAL_ERROR "not found (install via 'pip install nanobind' or set nanobind_DIR)")
endif()
message(STATUS "found (${PACKAGE_DIR})")
set(nanobind_DIR "${PACKAGE_DIR}")
@@ -73,8 +72,7 @@ macro(mlir_configure_python_dev_packages)
OUTPUT_VARIABLE PACKAGE_DIR
ERROR_QUIET)
if(NOT STATUS EQUAL "0")
- message(STATUS "not found (install via 'pip install nanobind' or set nanobind_DIR)")
- return()
+ message(FATAL_ERROR "not found (install via 'pip install nanobind' or set nanobind_DIR)")
endif()
set(nanobind_INCLUDE_DIR "${PACKAGE_DIR}")
endif()
|
makslevental
approved these changes
Jan 6, 2026
ftynse
approved these changes
Jan 7, 2026
jpienaar
approved these changes
Jan 8, 2026
Contributor
|
@uenoku cool feel free to merge whenever |
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.
Remove problematic
return()statements from mlir_configure_python_dev_packages macro and convert nanobind detection to FATAL_ERROR.Using
return()in a CMake macro is problematic because it returns from the calling scope, not the macro itself, causing the parent CMakeLists.txt to silently skip subsequent configuration steps. This leads to confusing build failures when Python bindings are enabled but nanobind is missing.With this change, users get an immediate error with clear instructions to install nanobind or set nanobind_DIR, rather than silent configuration failures.