Skip to content

Commit 82361e7

Browse files
authored
fix: Support importlib_metadata v5.0.0 (#5840)
* fix: Support importlib_metadata v5.0.0 importlib_metadata removed compatibility shims for deprecated entry point interfaces. see: https://github.com/python/importlib_metadata/blob/main/CHANGES.rst#v500 Filter result of entry_points function by group parameter. see: https://importlib-metadata.readthedocs.io/en/latest/api.html#importlib_metadata.entry_points * fix: Enable to run in older python version In circleci frontend-unit-tests, old node image is used and python 3.5 is used. Support both old version and latest version by checking ijmportlib_metadata version
1 parent 5cf13af commit 82361e7

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

bin/bundle-extensions

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,18 @@ def load_bundles():
6565
6666
"""
6767
bundles = odict()
68-
for entry_point in importlib_metadata.entry_points().get("redash.bundles", []):
68+
# HACK:
69+
# bin/bundle-extensions is tested in different versions.
70+
# circleci frontend-unit-tests: python 3.5 and importlib-metadata-2.1.3
71+
# circleci backend-unit-tests: python 3.7 and importlib-metadata-5.0.0
72+
if importlib_metadata.version("importlib_metadata") >= "5.0.0":
73+
bundles_entry_points = importlib_metadata.entry_points(group="redash.bundles")
74+
else:
75+
bundles_entry_points = importlib_metadata.entry_points().get(
76+
"redash.bundles", []
77+
)
78+
79+
for entry_point in bundles_entry_points:
6980
logger.info('Loading Redash bundle "%s".', entry_point.name)
7081
module = entry_point_module(entry_point)
7182
# Try to get a list of bundle files

redash/extensions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def entry_point_loader(group_name, mapping, logger=None, *args, **kwargs):
2727
if logger is None:
2828
logger = extension_logger
2929

30-
for entry_point in entry_points().get(group_name, []):
30+
for entry_point in entry_points(group=group_name):
3131
logger.info('Loading entry point "%s".', entry_point.name)
3232
try:
3333
# Then try to load the entry point (import and getattr)

0 commit comments

Comments
 (0)