Skip to content

Commit

Permalink
make finding kraken tools backward compatible with pkg_resources
Browse files Browse the repository at this point in the history
  • Loading branch information
godfryd committed Oct 25, 2023
1 parent 103b02e commit f4b4d1e
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions agent/kraken/agent/jobber.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,17 @@ def _load_tools_list():
spec = finder.find_spec(name)
tools[n] = spec.origin

eps = importlib.metadata.entry_points()
for entry_point in eps['kraken.tools']:
entry_point.load()
# log.info("TOOL %s: %s", entry_point.name, entry_point.module_name)
tools[entry_point.name] = (None, entry_point.module)
if sys.version_info.minor < 9: # if older than 3.9
import pkg_resources
for entry_point in pkg_resources.iter_entry_points('kraken.tools'):
entry_point.load()
tools[entry_point.name] = (None, entry_point.module_name)
else:
eps = importlib.metadata.entry_points()
for entry_point in eps['kraken.tools']:
entry_point.load()
# log.info("TOOL %s: %s", entry_point.name, entry_point.module_name)
tools[entry_point.name] = (None, entry_point.module)

return tools

Expand Down

0 comments on commit f4b4d1e

Please sign in to comment.