Skip to content

Commit

Permalink
[mlir][python][cmake] Allows for specifying NB_DOMAIN in `add_mlir_…
Browse files Browse the repository at this point in the history
…python_extension` (llvm#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)
  • Loading branch information
erwei-xilinx authored Jan 16, 2025
1 parent 77803e4 commit 9e863cd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
2 changes: 2 additions & 0 deletions mlir/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ configure_file(
# disable all package setup and control it themselves.
#-------------------------------------------------------------------------------

set(MLIR_BINDINGS_PYTHON_NB_DOMAIN "mlir"
CACHE STRING "nanobind domain for MLIR python bindings.")
set(MLIR_ENABLE_BINDINGS_PYTHON 0 CACHE BOOL
"Enables building of Python bindings.")
set(MLIR_DETECT_PYTHON_ENV_PRIME_SEARCH 1 CACHE BOOL
Expand Down
2 changes: 1 addition & 1 deletion mlir/cmake/modules/AddMLIRPython.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ function(add_mlir_python_extension libname extname)
)
elseif(ARG_PYTHON_BINDINGS_LIBRARY STREQUAL "nanobind")
nanobind_add_module(${libname}
NB_DOMAIN mlir
NB_DOMAIN ${MLIR_BINDINGS_PYTHON_NB_DOMAIN}
FREE_THREADED
${ARG_SOURCES}
)
Expand Down

0 comments on commit 9e863cd

Please sign in to comment.