Index: mlir/python/mlir/_mlir_libs/__init__.py =================================================================== --- mlir/python/mlir/_mlir_libs/__init__.py +++ mlir/python/mlir/_mlir_libs/__init__.py @@ -53,6 +53,7 @@ import importlib import itertools import logging + import sys from ._mlir import ir registry = ir.DialectRegistry() post_init_hooks = [] @@ -62,6 +63,12 @@ m = importlib.import_module(f".{module_name}", __name__) except ModuleNotFoundError: return False + except ImportError: + message = (f"Error importing mlir initializer {module_name}. This may " + "happen in unclean incremental builds but is likely a real bug if " + "encountered otherwise and the MLIR Python API may not function.") + logging.critical(message, exc_info=True) + sys.exit(1) logging.debug("Initializing MLIR with module: %s", module_name) if hasattr(m, "register_dialects"):