[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)
This commit is contained in:
erwei-xilinx 2025-01-16 07:26:29 -08:00 committed by GitHub
parent 77803e461c
commit 9e863cd449
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View File

@ -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

View File

@ -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}
)