[Python] Using `DefaultingPyMlirContext` out of tree

Is there some way to use the very nice default context feature of the python bindings outside of tree? I’m creating an attribute binding (in CIRCT) and it needs an MlirContext, which I’d rather users not have to provide (in the common case).

I think we just made the default adapters for the MlirContext type do this: llvm-project/PybindAdaptors.h at 93d08acaacec951dbb302f77eeae51974985b6b2 · llvm/llvm-project · GitHub

The TODO in there is for a better error message, but I believe it functionally does the right thing.

Sorry, I forgot about that code. I could’ve sworn I tried that and it didn’t work, but I’m probably just doing something stupid. (This was sometime last week.)

Yep. Something stupid on my end. I was missing the default argument. py::arg("ctxt")py::arg("ctxt") = py::none(). Sorry for the noise.