Add '__pyo3_version__` to native modules compiled with PyO3
From https://github.com/sphinx-doc/sphinx/issues/11662#issuecomment-1702462095
To be cheeky, could I ask if there is there a 'blessed' way to introspect if a module is PyO3 generated? It seems the variables mod.build_profile and mod.build_info might be heuristics, but a PYO3 = True flag or similar (a la 'pypy' in sys.modules) might be useful for future cases?
I can't think of one which exists right now, it seems like a practical improvement to have __pyo3_version__ as a standard attribute in compiled PyO3 modules?
In my experience, if a name is addressing two concerns (i.e. PyO3 and version), it's often wise to actually model those concerns separately, similar to how __spec__ models details about a modules spec. Please consider adding the detail as __pyo3__.version or similar.
Removing Good First Issue as this probably requires integration with the pyo3-runtime Python module to be completed.