Skip to content

Commit

Permalink
Add workaround to py3.8/py3.9 entry point loader to avoid bug where i…
Browse files Browse the repository at this point in the history
…mportlib returns duplicate dist entries. #16
  • Loading branch information
amykyta3 committed Mar 23, 2023
1 parent 8011ff6 commit 104e763
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/peakrdl/plugins/entry_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@ def _get_name_from_dist(dist: 'Distribution') -> str:

def _get_entry_points(group_name: str) -> List[Tuple['EntryPoint', 'Distribution']]:
eps = []
dist_names = set()
for dist in metadata.distributions():
# Due to a bug in importlib.metadata's distributions iterator, in
# some cases editable installs will cause duplicate dist entries.
# Filter this out.
dist_name = get_name_from_dist(dist)
if dist_name in dist_names:
continue
dist_names.add(dist_name)

for ep in dist.entry_points:
if ep.group == group_name:
eps.append((ep, dist))
Expand Down

0 comments on commit 104e763

Please sign in to comment.