[Mlir-commits] [mlir] [MLIR][Python] Drop Python 3.10 and enable Python 3.15 (PR #232181)
Maksim Levental
llvmlistbot at llvm.org
Thu Oct 15 09:54:03 PDT 2026
https://github.com/makslevental updated https://github.com/llvm/llvm-project/pull/232181
>From 446ce70cadaa91a471922c16665bd7e61620bb4e Mon Sep 17 00:00:00 2001
From: makslevental <maksim.levental at gmail.com>
Date: Wed, 14 Oct 2026 22:33:44 -0700
Subject: [PATCH 1/4] [MLIR][Python] Drop Python 3.10 and enable Python 3.15
Python 3.10 is EOL, so raise MLIR_MINIMUM_PYTHON_VERSION to 3.11.
For Python 3.15:
- Require nanobind >= 2.13. Earlier versions' darwin-ld-cpython.sym lacks
PyFrozenDict_Type (new in 3.15), so linking the bindings against 3.15
fails on macOS with an undefined symbol.
- Raise the numpy cap to 2.5.4; numpy <= 2.4 has no cp315 wheels.
---
mlir/cmake/modules/MLIRDetectPythonEnv.cmake | 4 ++--
mlir/examples/standalone/pyproject.toml | 6 +++---
mlir/python/requirements.txt | 4 ++--
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/mlir/cmake/modules/MLIRDetectPythonEnv.cmake b/mlir/cmake/modules/MLIRDetectPythonEnv.cmake
index 5ff28d88110d4c..bf598c56848bcb 100644
--- a/mlir/cmake/modules/MLIRDetectPythonEnv.cmake
+++ b/mlir/cmake/modules/MLIRDetectPythonEnv.cmake
@@ -1,6 +1,6 @@
# Macros and functions related to detecting details of the Python environment.
-set(MLIR_MINIMUM_PYTHON_VERSION 3.10)
+set(MLIR_MINIMUM_PYTHON_VERSION 3.11)
# Finds and configures python packages needed to build MLIR Python bindings.
macro(mlir_configure_python_dev_packages)
if(NOT MLIR_DISABLE_CONFIGURE_PYTHON_DEV_PACKAGES)
@@ -81,7 +81,7 @@ macro(mlir_configure_python_dev_packages)
endif()
set(nanobind_INCLUDE_DIR "${PACKAGE_DIR}")
endif()
- find_package(nanobind 2.9 CONFIG REQUIRED)
+ find_package(nanobind 2.13 CONFIG REQUIRED)
message(STATUS "Found nanobind v${nanobind_VERSION}")
endif()
endmacro()
diff --git a/mlir/examples/standalone/pyproject.toml b/mlir/examples/standalone/pyproject.toml
index 8fe29d6f897c48..106c9d79b74e7f 100644
--- a/mlir/examples/standalone/pyproject.toml
+++ b/mlir/examples/standalone/pyproject.toml
@@ -6,9 +6,9 @@
[project]
name = "standalone-python-bindings"
version = "0.0.1"
-requires-python = ">=3.8"
+requires-python = ">=3.11"
dependencies = [
- "numpy>=1.19.5, <=2.1.2",
+ "numpy>=1.19.5, <=2.5.4",
"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'",
@@ -24,7 +24,7 @@ Discussions = "https://discourse.llvm.org/"
requires = [
"scikit-build-core>=0.10.7",
"typing_extensions>=4.12.2",
- "nanobind>=2.9, <3.0",
+ "nanobind>=2.13, <3.0",
]
build-backend = "scikit_build_core.build"
diff --git a/mlir/python/requirements.txt b/mlir/python/requirements.txt
index d35cb894f21a5a..114008a2555f51 100644
--- a/mlir/python/requirements.txt
+++ b/mlir/python/requirements.txt
@@ -1,7 +1,7 @@
# BUILD dependencies
-nanobind>=2.9, <3.0
+nanobind>=2.13, <3.0
PyYAML>=5.4.0, <=6.0.3
typing_extensions>=4.12.2
# RUN dependencies
-numpy>=2.1.0, <=2.1.2
+numpy>=2.1.0, <=2.5.4
ml_dtypes>=0.5.0, <=0.6.0
>From 26b70384ef33a76c71b0764d5a6361d3e92120b4 Mon Sep 17 00:00:00 2001
From: makslevental <maksim.levental at gmail.com>
Date: Thu, 15 Oct 2026 09:49:34 -0700
Subject: [PATCH 2/4] [MLIR][Python] Only require nanobind 2.13 for Python 3.15
Keep the nanobind minimum at 2.9 for Python < 3.15 instead of raising it
for everyone; only 3.15 needs 2.13 (for PyFrozenDict_Type in
darwin-ld-cpython.sym on macOS).
---
mlir/cmake/modules/MLIRDetectPythonEnv.cmake | 10 +++++++++-
mlir/examples/standalone/pyproject.toml | 3 ++-
mlir/python/requirements.txt | 3 ++-
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/mlir/cmake/modules/MLIRDetectPythonEnv.cmake b/mlir/cmake/modules/MLIRDetectPythonEnv.cmake
index bf598c56848bcb..2424e5c94a8bab 100644
--- a/mlir/cmake/modules/MLIRDetectPythonEnv.cmake
+++ b/mlir/cmake/modules/MLIRDetectPythonEnv.cmake
@@ -81,7 +81,15 @@ macro(mlir_configure_python_dev_packages)
endif()
set(nanobind_INCLUDE_DIR "${PACKAGE_DIR}")
endif()
- find_package(nanobind 2.13 CONFIG REQUIRED)
+ # nanobind < 2.13 doesn't list Python 3.15's PyFrozenDict_Type in
+ # darwin-ld-cpython.sym, so linking against 3.15 fails on macOS.
+ if(Python3_VERSION VERSION_GREATER_EQUAL 3.15)
+ set(_nanobind_min_version 2.13)
+ else()
+ set(_nanobind_min_version 2.9)
+ endif()
+ find_package(nanobind ${_nanobind_min_version} CONFIG REQUIRED)
+ unset(_nanobind_min_version)
message(STATUS "Found nanobind v${nanobind_VERSION}")
endif()
endmacro()
diff --git a/mlir/examples/standalone/pyproject.toml b/mlir/examples/standalone/pyproject.toml
index 106c9d79b74e7f..6733e369700fd4 100644
--- a/mlir/examples/standalone/pyproject.toml
+++ b/mlir/examples/standalone/pyproject.toml
@@ -24,7 +24,8 @@ Discussions = "https://discourse.llvm.org/"
requires = [
"scikit-build-core>=0.10.7",
"typing_extensions>=4.12.2",
- "nanobind>=2.13, <3.0",
+ "nanobind>=2.9, <3.0; python_version<'3.15'",
+ "nanobind>=2.13, <3.0; python_version>='3.15'",
]
build-backend = "scikit_build_core.build"
diff --git a/mlir/python/requirements.txt b/mlir/python/requirements.txt
index 114008a2555f51..ed70e0f43bfa0c 100644
--- a/mlir/python/requirements.txt
+++ b/mlir/python/requirements.txt
@@ -1,5 +1,6 @@
# BUILD dependencies
-nanobind>=2.13, <3.0
+nanobind>=2.9, <3.0; python_version<'3.15'
+nanobind>=2.13, <3.0; python_version>='3.15'
PyYAML>=5.4.0, <=6.0.3
typing_extensions>=4.12.2
# RUN dependencies
>From 9e1c661e5e0e10278198b9b66e10f9ec35a5914a Mon Sep 17 00:00:00 2001
From: makslevental <maksim.levental at gmail.com>
Date: Thu, 15 Oct 2026 09:50:54 -0700
Subject: [PATCH 3/4] [MLIR][Python] Only raise numpy/ml_dtypes minimums for
Python 3.15
Use python_version markers instead of raising the numpy cap for everyone:
Python < 3.15 keeps numpy <= 2.1.2, and 3.15 gets numpy 2.5.x and
ml_dtypes 0.6.0 (the first releases with cp315 wheels).
---
mlir/examples/standalone/pyproject.toml | 6 ++++--
mlir/python/requirements.txt | 6 ++++--
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/mlir/examples/standalone/pyproject.toml b/mlir/examples/standalone/pyproject.toml
index 6733e369700fd4..135105b536a26a 100644
--- a/mlir/examples/standalone/pyproject.toml
+++ b/mlir/examples/standalone/pyproject.toml
@@ -8,10 +8,12 @@ name = "standalone-python-bindings"
version = "0.0.1"
requires-python = ">=3.11"
dependencies = [
- "numpy>=1.19.5, <=2.5.4",
+ "numpy>=1.19.5, <=2.1.2; python_version<'3.15'",
+ "numpy>=2.5.0, <=2.5.4; python_version>='3.15'",
"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'",
+ "ml_dtypes>=0.5.0, <=0.6.0; python_version>='3.13' and python_version<'3.15'",
+ "ml_dtypes>=0.6.0, <=0.6.0; python_version>='3.15'",
]
[project.urls]
diff --git a/mlir/python/requirements.txt b/mlir/python/requirements.txt
index ed70e0f43bfa0c..07ba29a872dfeb 100644
--- a/mlir/python/requirements.txt
+++ b/mlir/python/requirements.txt
@@ -4,5 +4,7 @@ nanobind>=2.13, <3.0; python_version>='3.15'
PyYAML>=5.4.0, <=6.0.3
typing_extensions>=4.12.2
# RUN dependencies
-numpy>=2.1.0, <=2.5.4
-ml_dtypes>=0.5.0, <=0.6.0
+numpy>=2.1.0, <=2.1.2; python_version<'3.15'
+numpy>=2.5.0, <=2.5.4; python_version>='3.15'
+ml_dtypes>=0.5.0, <=0.6.0; python_version<'3.15'
+ml_dtypes>=0.6.0, <=0.6.0; python_version>='3.15'
>From 0272d29ff12f01a2d8de5ec61f9addc9cb9629c1 Mon Sep 17 00:00:00 2001
From: makslevental <maksim.levental at gmail.com>
Date: Thu, 15 Oct 2026 09:53:30 -0700
Subject: [PATCH 4/4] [MLIR][Python] Pin ml_dtypes with == for Python 3.15
---
mlir/examples/standalone/pyproject.toml | 2 +-
mlir/python/requirements.txt | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/mlir/examples/standalone/pyproject.toml b/mlir/examples/standalone/pyproject.toml
index 135105b536a26a..287f84ff6b892b 100644
--- a/mlir/examples/standalone/pyproject.toml
+++ b/mlir/examples/standalone/pyproject.toml
@@ -13,7 +13,7 @@ dependencies = [
"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' and python_version<'3.15'",
- "ml_dtypes>=0.6.0, <=0.6.0; python_version>='3.15'",
+ "ml_dtypes==0.6.0; python_version>='3.15'",
]
[project.urls]
diff --git a/mlir/python/requirements.txt b/mlir/python/requirements.txt
index 07ba29a872dfeb..de1e15c9ce3c25 100644
--- a/mlir/python/requirements.txt
+++ b/mlir/python/requirements.txt
@@ -7,4 +7,4 @@ typing_extensions>=4.12.2
numpy>=2.1.0, <=2.1.2; python_version<'3.15'
numpy>=2.5.0, <=2.5.4; python_version>='3.15'
ml_dtypes>=0.5.0, <=0.6.0; python_version<'3.15'
-ml_dtypes>=0.6.0, <=0.6.0; python_version>='3.15'
+ml_dtypes==0.6.0; python_version>='3.15'
More information about the Mlir-commits
mailing list