[Mlir-commits] [mlir] 653d0d0 - [mlir][python] add `MLIR_BINDINGS_PYTHON_INSTALL_PREFIX` to make bindings install dir configurable (#124878)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Jun 23 12:49:04 PDT 2025


Author: Maksim Levental
Date: 2025-06-23T15:49:01-04:00
New Revision: 653d0d007375d421875f91ae758b4189ce8e02b2

URL: https://github.com/llvm/llvm-project/commit/653d0d007375d421875f91ae758b4189ce8e02b2
DIFF: https://github.com/llvm/llvm-project/commit/653d0d007375d421875f91ae758b4189ce8e02b2.diff

LOG: [mlir][python] add `MLIR_BINDINGS_PYTHON_INSTALL_PREFIX` to make bindings install dir configurable (#124878)

This PR parameterizes the install directory of the MLIR Python bindings in the final distribution.

Added: 
    

Modified: 
    mlir/CMakeLists.txt
    mlir/python/CMakeLists.txt

Removed: 
    


################################################################################
diff  --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt
index 44493b75b8a8c..a1ad81f625cd6 100644
--- a/mlir/CMakeLists.txt
+++ b/mlir/CMakeLists.txt
@@ -184,6 +184,8 @@ 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_BINDINGS_PYTHON_INSTALL_PREFIX "python_packages/mlir_core/mlir" CACHE STRING
+       "Prefix under install directory to place python bindings")
 set(MLIR_DETECT_PYTHON_ENV_PRIME_SEARCH 1 CACHE BOOL
        "Prime the python detection by searching for a full 'Development' \
        component first (temporary while diagnosing environment specific Python \

diff  --git a/mlir/python/CMakeLists.txt b/mlir/python/CMakeLists.txt
index e3934fc9f3511..ee07081246fc7 100644
--- a/mlir/python/CMakeLists.txt
+++ b/mlir/python/CMakeLists.txt
@@ -356,7 +356,7 @@ declare_mlir_dialect_python_bindings(
   ADD_TO_PARENT MLIRPythonSources.Dialects
   ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/mlir"
   TD_FILE dialects/EmitC.td
-  SOURCES 
+  SOURCES
     dialects/emitc.py
   DIALECT_NAME emitc)
 
@@ -790,7 +790,7 @@ endif()
 
 add_mlir_python_common_capi_library(MLIRPythonCAPI
   INSTALL_COMPONENT MLIRPythonModules
-  INSTALL_DESTINATION python_packages/mlir_core/mlir/_mlir_libs
+  INSTALL_DESTINATION "${MLIR_BINDINGS_PYTHON_INSTALL_PREFIX}/_mlir_libs"
   OUTPUT_DIRECTORY "${MLIR_BINARY_DIR}/python_packages/mlir_core/mlir/_mlir_libs"
   RELATIVE_INSTALL_ROOT "../../../.."
   DECLARED_HEADERS
@@ -821,7 +821,7 @@ endif()
 
 add_mlir_python_modules(MLIRPythonModules
   ROOT_PREFIX "${MLIR_BINARY_DIR}/python_packages/mlir_core/mlir"
-  INSTALL_PREFIX "python_packages/mlir_core/mlir"
+  INSTALL_PREFIX "${MLIR_BINDINGS_PYTHON_INSTALL_PREFIX}"
   DECLARED_SOURCES
     MLIRPythonSources
     MLIRPythonExtension.RegisterEverything


        


More information about the Mlir-commits mailing list