Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compatibility with Python < 3.10 importlib.metadata #585

Merged
merged 1 commit into from
Sep 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions colcon_core/extension_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ def get_all_extension_points():
entry_points = defaultdict(dict)
seen = set()
for dist in distributions():
if dist.name in seen:
dist_name = dist.metadata['Name']
if dist_name in seen:
continue
seen.add(dist.name)
seen.add(dist_name)
for entry_point in dist.entry_points:
# skip groups which are not registered as extension points
if entry_point.group not in colcon_extension_points:
Expand All @@ -69,7 +70,7 @@ def get_all_extension_points():
f"from '{dist._path}' "
f"overwriting '{previous}'")
entry_points[entry_point.group][entry_point.name] = \
(entry_point.value, dist.name, dist.version)
(entry_point.value, dist_name, dist.version)
return entry_points


Expand Down
6 changes: 5 additions & 1 deletion test/test_extension_point.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ class Dist():
version = '0.0.0'

def __init__(self, entry_points):
self.name = f'dist-{id(self)}'
self.metadata = {'Name': f'dist-{id(self)}'}
self._entry_points = entry_points

@property
def entry_points(self):
return list(self._entry_points)

@property
def name(self):
return self.metadata['Name']


def iter_entry_points(*, group=None):
if group == EXTENSION_POINT_GROUP_NAME:
Expand Down