From 5f9c0e7400f7f2383426db9ac57cda1f39529142 Mon Sep 17 00:00:00 2001 From: max Date: Tue, 28 Jan 2025 23:52:11 -0500 Subject: [PATCH 1/3] [mlir][python] add pyproject.toml --- mlir/CMakeLists.txt | 2 ++ mlir/python/CMakeLists.txt | 6 +++--- mlir/python/pyproject.toml | 40 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 mlir/python/pyproject.toml diff --git a/mlir/CMakeLists.txt b/mlir/CMakeLists.txt index 9e786154a2b40..3b04244d23d37 100644 --- a/mlir/CMakeLists.txt +++ b/mlir/CMakeLists.txt @@ -178,6 +178,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 fb115a5f43423..bf6627904f866 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) @@ -764,7 +764,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 @@ -795,7 +795,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 diff --git a/mlir/python/pyproject.toml b/mlir/python/pyproject.toml new file mode 100644 index 0000000000000..6845df9fd5c1a --- /dev/null +++ b/mlir/python/pyproject.toml @@ -0,0 +1,40 @@ +# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +# See https://llvm.org/LICENSE.txt for license information. +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +# Copyright (c) 2025. + +[project] +name = "mlir-python-bindings" +version = "0.0.1" +requires-python = ">=3.8,<=3.13" +[project.urls] +Homepage = "https://github.com/llvm/llvm-project" + +[build-system] +requires = [ + "scikit-build-core==0.10.7", + "typing_extensions==4.12.2", + "nanobind>=2.4, <3.0", + "numpy>=1.19.5, <=2.1.2", + "pybind11>=2.10.0, <=2.13.6", + "PyYAML>=5.4.0, <=6.0.1", + 'ml_dtypes>=0.1.0, <=0.6.0; python_version<"3.13"', + 'ml_dtypes>=0.5.0, <=0.6.0; python_version>="3.13"' +] +build-backend = "scikit_build_core.build" + +[tool.scikit-build] +minimum-version = "0.10" +build-dir = "../../build" +cmake.source-dir = "../../llvm" +wheel.exclude = ["bin", "include", "lib", "src", "share"] +build.targets = ["MLIRPythonModules"] + +[tool.scikit-build.cmake.define] +CMAKE_C_COMPILER_LAUNCHER = { env = "CMAKE_C_COMPILER_LAUNCHER", default = "" } +CMAKE_CXX_COMPILER_LAUNCHER = { env = "CMAKE_CXX_COMPILER_LAUNCHER", default = "" } +CMAKE_CXX_VISIBILITY_PRESET = "hidden" +CMAKE_VERBOSE_MAKEFILE = "ON" +LLVM_ENABLE_PROJECTS = "mlir" +MLIR_ENABLE_BINDINGS_PYTHON = "ON" +MLIR_BINDINGS_PYTHON_INSTALL_PREFIX = "mlir" From 703f6dce4bb51e569121ae8777095e9470de2ecc Mon Sep 17 00:00:00 2001 From: Maksim Levental Date: Mon, 10 Feb 2025 15:33:05 -0500 Subject: [PATCH 2/3] Update mlir/python/pyproject.toml Co-authored-by: Ryan Mast <3969255+nightlark@users.noreply.github.com> --- mlir/python/pyproject.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mlir/python/pyproject.toml b/mlir/python/pyproject.toml index 6845df9fd5c1a..4abaa2416826d 100644 --- a/mlir/python/pyproject.toml +++ b/mlir/python/pyproject.toml @@ -9,6 +9,9 @@ version = "0.0.1" requires-python = ">=3.8,<=3.13" [project.urls] Homepage = "https://github.com/llvm/llvm-project" +Discussions = "https://discourse.llvm.org/" +"Issue Tracker" = "https://github.com/llvm/llvm-project/issues?q=is%3Aissue%20state%3Aopen%20label%3Amlir%3Apython%20" +"Source Code" = "https://github.com/llvm/llvm-project/tree/main/mlir/python" [build-system] requires = [ From 2f0d7fa4f65e140563af6a6acb056b5176dd8b15 Mon Sep 17 00:00:00 2001 From: Maksim Levental Date: Mon, 23 Jun 2025 11:00:03 -0400 Subject: [PATCH 3/3] Delete mlir/python/pyproject.toml --- mlir/python/pyproject.toml | 43 -------------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 mlir/python/pyproject.toml diff --git a/mlir/python/pyproject.toml b/mlir/python/pyproject.toml deleted file mode 100644 index 4abaa2416826d..0000000000000 --- a/mlir/python/pyproject.toml +++ /dev/null @@ -1,43 +0,0 @@ -# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. -# See https://llvm.org/LICENSE.txt for license information. -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -# Copyright (c) 2025. - -[project] -name = "mlir-python-bindings" -version = "0.0.1" -requires-python = ">=3.8,<=3.13" -[project.urls] -Homepage = "https://github.com/llvm/llvm-project" -Discussions = "https://discourse.llvm.org/" -"Issue Tracker" = "https://github.com/llvm/llvm-project/issues?q=is%3Aissue%20state%3Aopen%20label%3Amlir%3Apython%20" -"Source Code" = "https://github.com/llvm/llvm-project/tree/main/mlir/python" - -[build-system] -requires = [ - "scikit-build-core==0.10.7", - "typing_extensions==4.12.2", - "nanobind>=2.4, <3.0", - "numpy>=1.19.5, <=2.1.2", - "pybind11>=2.10.0, <=2.13.6", - "PyYAML>=5.4.0, <=6.0.1", - 'ml_dtypes>=0.1.0, <=0.6.0; python_version<"3.13"', - 'ml_dtypes>=0.5.0, <=0.6.0; python_version>="3.13"' -] -build-backend = "scikit_build_core.build" - -[tool.scikit-build] -minimum-version = "0.10" -build-dir = "../../build" -cmake.source-dir = "../../llvm" -wheel.exclude = ["bin", "include", "lib", "src", "share"] -build.targets = ["MLIRPythonModules"] - -[tool.scikit-build.cmake.define] -CMAKE_C_COMPILER_LAUNCHER = { env = "CMAKE_C_COMPILER_LAUNCHER", default = "" } -CMAKE_CXX_COMPILER_LAUNCHER = { env = "CMAKE_CXX_COMPILER_LAUNCHER", default = "" } -CMAKE_CXX_VISIBILITY_PRESET = "hidden" -CMAKE_VERBOSE_MAKEFILE = "ON" -LLVM_ENABLE_PROJECTS = "mlir" -MLIR_ENABLE_BINDINGS_PYTHON = "ON" -MLIR_BINDINGS_PYTHON_INSTALL_PREFIX = "mlir"