[Mlir-commits] [mlir] [MLIR][Python] Extend bindings for external projects without duplication (PR #173241)
Sylvain Noiry
llvmlistbot at llvm.org
Tue Dec 23 07:39:03 PST 2025
ElectrikSpace 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 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
> I understand you don't intend to - I'm saying you have to _make sure_ it doesn't negatively affect anyone else's project.
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.
> Regarding those paths: you might've noticed there are actually a lot of sources (all of them?) which use relative paths. Changing the generated ones won't solve the hand-written ones which cannot be configured at build time (`configure_file` exists but that would break their legality as actual python source in the repo source tree).
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`. For example my `add_mlir_python_modules` looks like this (project name is SDist):
```
add_mlir_python_modules(SDistPythonModules
ROOT_PREFIX "${MLIR_BINARY_DIR}/python_packages/sdist/mlir_sdist"
INSTALL_PREFIX "python_packages/sdist/mlir_sdist"
DECLARED_SOURCES
SDistPythonSources
SDistPythonSources.Extension
COMMON_CAPI_LINK_LIBS
MLIRPythonCAPI
SDistPythonCAPI
)
```
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.
https://github.com/llvm/llvm-project/pull/173241
More information about the Mlir-commits
mailing list