If you don’t maintain an out of tree project that uses the MLIR Python bindings as part of a larger super-project, you can stop reading.
There is work beginning to support nanobind for writing dialect extensions. Currently, the MLIR Python bindings are based on pybind11, but the intent was that this was always an implementation detail versus a hard coupling. Some of us are keen to go further and use nanobind throughout based on the extreme reductions in compile time/size and improved performance it brings – but that is a topic for a different day.
What this means for right now is that MLIR itself is about to grow a dependency on nanobind. This is needed to run the test suite, etc, and is not too different from other dependencies MLIR carries for completeness.
However, the way that MLIR and super-projects that use it collaborate on setting up Python development package dependencies has always been very fragile since there are multiple ways to instruct CMake to set up Python and pybind/nanobind/etc and the way that some of this stuff is distributed is not universally compatible. In the past, changes like this have caused a set of rolling issues across projects as folks integrate the patch and need to adapt build systems and CI infra in opaque ways.
To make this better for the future, I landed [mlir] Add option to disable MLIR Python dev package configuration. by stellaraccident · Pull Request #117934 · llvm/llvm-project · GitHub which adds an option MLIR_DISABLE_CONFIGURE_PYTHON_DEV_PACKAGES
. If this is set, then the mlir_configure_python_dev_packages
macro will no-op. In this case, the super-project is wholly responsible for providing the needed build dependencies, which is basically the equivalent of this today:
find_package(Python3 3.10 COMPONENTS Interpreter Development.Module REQUIRED)
find_package(pybind11)
If using the new nanobind support once that lands, that will also require an incantation as documented here.
It is always up to the super project to ensure that single, project wide dependencies are resolved properly. I’d recommend that if you manage such a project, that you set the above option and configure the components yourself so that you are future proof and have one easy place to change (in our project, we use FetchContent, but the best options require CMake versions that LLVM itself does not yet support and you are better off just owning this configuration downstream where you can set your own CMake version policy).
You can keep using it as-is if desired, but in the world we are heading to, the mlir_configure_python_dev_packages
macro is really an implementation detail of MLIR itself, and using the above CMake option lets you insulate yourself from changes and conflicts that are going to cause churn there.