Use stdlib importlib.metadata where possible
The importlib_metadata package isn't guaranteed to be available, but the
stlib version will always be there (at least on Python 3.8 or later).
@@ -22,6 +22,11 @@ import itertools
import operator
import sys
+# TODO(stephenfin): Remove this once we drop support for Python < 3.8
+if sys.version_info >= (3, 8):
+ from importlib import metadata as importlib_metadata
+ use_importlib = True
+else:
try:
import importlib_metadata
use_importlib = True
