Python bindings and Bazel

Hi there,

I’m trying to package the MLIR Python bindings using bazel (via py_package/py_wheel) in a downstream project, but hitting some issues.

I’m curious if I’m holding it wrong, or if it’s just not fully supported at the moment?
Has anyone built such a package successfully?


Some of the issues I’m seeing after installing the whl:

  • Most of the files are not placed correctly (e.g., site-packages/mlir/python/mlir/*.py vs site-packages/mlir/*.py, _mlir.so is located under the root instead of _mlir_libs)
  • _mlirRegisterEverything.so is not defined in LLVM’s Bazel build files
  • MLIRPythonCAPI while perhaps not needed, is also not defined in LLVM’s Bazel build files

After some moves/remapping I managed to get decently looking whl similar in structure to what CMake produces, but hitting some other issues like missing dylibs, undefined symbols, etc.

1 Like