Skip to content

Commit 5f9c0e7

Browse files
committed
[mlir][python] add pyproject.toml
1 parent c1ec5be commit 5f9c0e7

File tree

3 files changed

+45
-3
lines changed

3 files changed

+45
-3
lines changed

mlir/CMakeLists.txt

+2
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,8 @@ set(MLIR_BINDINGS_PYTHON_NB_DOMAIN "mlir"
178178
CACHE STRING "nanobind domain for MLIR python bindings.")
179179
set(MLIR_ENABLE_BINDINGS_PYTHON 0 CACHE BOOL
180180
"Enables building of Python bindings.")
181+
set(MLIR_BINDINGS_PYTHON_INSTALL_PREFIX "python_packages/mlir_core/mlir" CACHE STRING
182+
"Prefix under install directory to place python bindings")
181183
set(MLIR_DETECT_PYTHON_ENV_PRIME_SEARCH 1 CACHE BOOL
182184
"Prime the python detection by searching for a full 'Development' \
183185
component first (temporary while diagnosing environment specific Python \

mlir/python/CMakeLists.txt

+3-3
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ declare_mlir_dialect_python_bindings(
356356
ADD_TO_PARENT MLIRPythonSources.Dialects
357357
ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/mlir"
358358
TD_FILE dialects/EmitC.td
359-
SOURCES
359+
SOURCES
360360
dialects/emitc.py
361361
DIALECT_NAME emitc)
362362

@@ -764,7 +764,7 @@ endif()
764764

765765
add_mlir_python_common_capi_library(MLIRPythonCAPI
766766
INSTALL_COMPONENT MLIRPythonModules
767-
INSTALL_DESTINATION python_packages/mlir_core/mlir/_mlir_libs
767+
INSTALL_DESTINATION "${MLIR_BINDINGS_PYTHON_INSTALL_PREFIX}/_mlir_libs"
768768
OUTPUT_DIRECTORY "${MLIR_BINARY_DIR}/python_packages/mlir_core/mlir/_mlir_libs"
769769
RELATIVE_INSTALL_ROOT "../../../.."
770770
DECLARED_HEADERS
@@ -795,7 +795,7 @@ endif()
795795

796796
add_mlir_python_modules(MLIRPythonModules
797797
ROOT_PREFIX "${MLIR_BINARY_DIR}/python_packages/mlir_core/mlir"
798-
INSTALL_PREFIX "python_packages/mlir_core/mlir"
798+
INSTALL_PREFIX "${MLIR_BINDINGS_PYTHON_INSTALL_PREFIX}"
799799
DECLARED_SOURCES
800800
MLIRPythonSources
801801
MLIRPythonExtension.RegisterEverything

mlir/python/pyproject.toml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
2+
# See https://llvm.org/LICENSE.txt for license information.
3+
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
4+
# Copyright (c) 2025.
5+
6+
[project]
7+
name = "mlir-python-bindings"
8+
version = "0.0.1"
9+
requires-python = ">=3.8,<=3.13"
10+
[project.urls]
11+
Homepage = "https://github.com/llvm/llvm-project"
12+
13+
[build-system]
14+
requires = [
15+
"scikit-build-core==0.10.7",
16+
"typing_extensions==4.12.2",
17+
"nanobind>=2.4, <3.0",
18+
"numpy>=1.19.5, <=2.1.2",
19+
"pybind11>=2.10.0, <=2.13.6",
20+
"PyYAML>=5.4.0, <=6.0.1",
21+
'ml_dtypes>=0.1.0, <=0.6.0; python_version<"3.13"',
22+
'ml_dtypes>=0.5.0, <=0.6.0; python_version>="3.13"'
23+
]
24+
build-backend = "scikit_build_core.build"
25+
26+
[tool.scikit-build]
27+
minimum-version = "0.10"
28+
build-dir = "../../build"
29+
cmake.source-dir = "../../llvm"
30+
wheel.exclude = ["bin", "include", "lib", "src", "share"]
31+
build.targets = ["MLIRPythonModules"]
32+
33+
[tool.scikit-build.cmake.define]
34+
CMAKE_C_COMPILER_LAUNCHER = { env = "CMAKE_C_COMPILER_LAUNCHER", default = "" }
35+
CMAKE_CXX_COMPILER_LAUNCHER = { env = "CMAKE_CXX_COMPILER_LAUNCHER", default = "" }
36+
CMAKE_CXX_VISIBILITY_PRESET = "hidden"
37+
CMAKE_VERBOSE_MAKEFILE = "ON"
38+
LLVM_ENABLE_PROJECTS = "mlir"
39+
MLIR_ENABLE_BINDINGS_PYTHON = "ON"
40+
MLIR_BINDINGS_PYTHON_INSTALL_PREFIX = "mlir"

0 commit comments

Comments
 (0)