The importlib-metadata package was imported to the core Python since
Python 3.8, and stevedore uses the standard library implementation
instead of the 3rd party package in Python 3.8 and later. However
the implementation available in Python 3.8 is quite old and especially
it does not include the change which added the module attribute[1].
This change makes sure we avoid referring to that attribute if it does
not exist, to avoid AttributeError in Python 3.8.
[1] dfc96137ac
Backport note:
This change includes an additional fix for Python < 3.8, which uses
the 3rd party importlib-metadata.
Story: 2010095
Task: 45650
Change-Id: Ieba5f353b0fe8a9b187bac1f6ff1b3a8f3b896b3
(cherry picked from commit eec1f92bc0)
(cherry picked from commit ecca0fcbeb)
(cherry picked from commit b8e27f7c47)