Skip to content

Commit 9e863cd

Browse files
authored
[mlir][python][cmake] Allows for specifying NB_DOMAIN in add_mlir_python_extension (#122865)
This PR allows the users to specify the `NB_DOMAIN` for `add_mlir_python_extension`. This allows users to avoid nanobind domain conflicts, when python bindings from multiple `mlir` projects were imported. (https://nanobind.readthedocs.io/en/latest/faq.html#how-can-i-avoid-conflicts-with-other-projects-using-nanobind)
1 parent 77803e4 commit 9e863cd

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

mlir/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ configure_file(
174174
# disable all package setup and control it themselves.
175175
#-------------------------------------------------------------------------------
176176

177+
set(MLIR_BINDINGS_PYTHON_NB_DOMAIN "mlir"
178+
CACHE STRING "nanobind domain for MLIR python bindings.")
177179
set(MLIR_ENABLE_BINDINGS_PYTHON 0 CACHE BOOL
178180
"Enables building of Python bindings.")
179181
set(MLIR_DETECT_PYTHON_ENV_PRIME_SEARCH 1 CACHE BOOL

mlir/cmake/modules/AddMLIRPython.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,7 @@ function(add_mlir_python_extension libname extname)
667667
)
668668
elseif(ARG_PYTHON_BINDINGS_LIBRARY STREQUAL "nanobind")
669669
nanobind_add_module(${libname}
670-
NB_DOMAIN mlir
670+
NB_DOMAIN ${MLIR_BINDINGS_PYTHON_NB_DOMAIN}
671671
FREE_THREADED
672672
${ARG_SOURCES}
673673
)

0 commit comments

Comments
 (0)