[all-commits] [llvm/llvm-project] e911eb: [MLIR][Python] Fix stubgen/PYTHONPATH collision/bu...

Maksim Levental via All-commits all-commits at lists.llvm.org
Mon Sep 29 22:38:16 PDT 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: e911eba3ef6990da2c4620c573b99a4f20f53da4
      https://github.com/llvm/llvm-project/commit/e911eba3ef6990da2c4620c573b99a4f20f53da4
  Author: Maksim Levental <maksim.levental at gmail.com>
  Date:   2025-09-30 (Tue, 30 Sep 2025)

  Changed paths:
    M mlir/cmake/modules/AddMLIRPython.cmake

  Log Message:
  -----------
  [MLIR][Python] Fix stubgen/PYTHONPATH collision/bug (#161307)

If `PYTHONPATH` is set and points to the build location of the python
bindings package then when stubgen runs, `_mlir` will get imported twice
and bad things will happen (e.g., `Assertion !instance && “PyGlobals
already constructed”’`). This happens because `mlir` is a namespace
package and the importer/loader can't distinguish between
`mlir._mlir_libs._mlir` and `_mlir_libs._mlir` imported from `CWD`. Or
something like that. The fix is to filter out any entries in
`PYTHONPATH` that end in `MLIR_BINDINGS_PYTHON_INSTALL_PREFIX/..` (e.g.,
`python_packages/mlir_core/`).



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list