Skip to content

Commit

Permalink
Use single call to importlib.metadata.entry_points for all groups
Browse files Browse the repository at this point in the history
  • Loading branch information
timonegk committed Sep 4, 2023
1 parent b49a395 commit 4da343a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
5 changes: 0 additions & 5 deletions catkin_tools/commands/catkin.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@
CATKIN_COMMAND_VERB_GROUP = 'catkin_tools.commands.catkin.verbs'


@functools.lru_cache(maxsize=None)
def _get_verb_entrypoints():
return list(entry_points(group=CATKIN_COMMAND_VERB_GROUP))


def list_verbs():
verbs = []
for entry_point in _get_verb_entrypoints():
Expand Down
18 changes: 11 additions & 7 deletions catkin_tools/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,19 @@

import os
import sys
import functools

if sys.version_info >= (3, 10):
from importlib.metadata import entry_points
else:
import importlib.metadata

def entry_points(*, group):
for ep in importlib.metadata.entry_points().get(group, []):
yield ep
def entry_points(*, group):
@functools.lru_cache(maxsize=None)
def _entry_points():
from importlib.metadata import entry_points
return entry_points()

if sys.version_info >= (3, 10):
return _entry_points().select(group=group)
else:
return _entry_points().get(group, [])


def which(program):
Expand Down

0 comments on commit 4da343a

Please sign in to comment.