[Mlir-commits] [mlir] [MLIR][Python] Extend bindings for external projects without duplication (PR #173241)
Maksim Levental
llvmlistbot at llvm.org
Tue Dec 23 08:20:07 PST 2025
makslevental wrote:
> > Ok but how will you "find" that lib when building/compiling/linking your "external" wheel? There's no more CMake exports at that point right?
>
> I have no other proper solution in mind than:
>
> * try to import mlir in python and find it with relative path
> * find the mlir package from the MLIR_DIR
> * rebuild it temporary to link with, and don't install it
> * LD_PRELOAD xD
And you're planning on doing this during build of the wheel? You realize that most times `pip wheel ...` builds in an isolated environment right? I.e., you have to pass `--no-build-isolation` to try to do what you want to do and that comes with its own quirks.
> Ok sure, but I didn't understand how the "pip-installable wheels" use case could be affected. You mean by the change from relative to absolute paths in generated files ?
Currently the patch includes the change to `add_mlir_aggregate` which like I said breaks current users. And I said maybe that breakage is worth it but overall I'm saying there are two things to check when reviewing a patch:
1. The patch actually accomplishes the stated goals;
2. The patch doesn't break current users *unless it's a worthwhile breakage*.
It's risk vs. reward. It's possible that just changing from relative to absolute would be risk free (after some re-design) but I still don't see the reward because I don't understand what you're actually trying to accomplish.
> Yes, I don't pretend to change these, because it does not affect upstream, and external projects don't use them if they want to link dynamically with `MLIRPythonCAPI`. ....
> Maybe we can put the use of absolute paths in `mlir-tblgen` optional, but I don't see another way to prevent duplication. I just tried to duplicate only `MLIRPythonSources.Core.Python` but this causes double initialization.
As I said I'm having a hard time understanding what exactly you're trying to de-duplicate. In which ever current environment where you have this working for you can you do
```shell
$ tree venv/lib/python3.13/site-packages/mlir_upstream
...
$ tree venv/lib/python3.13/site-packages/mlir_external
```
and paste the results here.
https://github.com/llvm/llvm-project/pull/173241
More information about the Mlir-commits
mailing list