Skip to content

Commit 853c00f

Browse files
Use importlib_metadata if importlib.data is unavailable
1 parent 192db0c commit 853c00f

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

opentelemetry-api/src/opentelemetry/util/_importlib_metadata.py

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,29 @@
1414

1515
# FIXME: Use importlib.metadata when support for 3.11 is dropped if the rest of
1616
# the supported versions at that time have the same API.
17-
from importlib.metadata import (
18-
Distribution,
19-
EntryPoint,
20-
EntryPoints,
21-
PackageNotFoundError,
22-
distributions,
23-
entry_points,
24-
requires,
25-
version,
26-
)
17+
try:
18+
from importlib.metadata import (
19+
Distribution,
20+
EntryPoint,
21+
EntryPoints,
22+
PackageNotFoundError,
23+
distributions,
24+
entry_points,
25+
requires,
26+
version,
27+
)
28+
except Exception:
29+
from importlib_metadata import (
30+
Distribution,
31+
EntryPoint,
32+
EntryPoints,
33+
PackageNotFoundError,
34+
distributions,
35+
entry_points,
36+
requires,
37+
version,
38+
)
39+
2740

2841
__all__ = [
2942
"entry_points",

0 commit comments

Comments
 (0)