|
6 | 6 |
|
7 | 7 | import sys, os, gc, optparse, logging, time, collections |
8 | 8 | import importlib, importlib.util |
9 | | -import importlib_metadata |
10 | 9 |
|
11 | 10 | from . import compat |
12 | 11 | from . import util, reactor, queuelogger, msgproto |
@@ -147,18 +146,17 @@ def load_object(self, config, section, default=configfile.sentinel): |
147 | 146 | plugins_spec = importlib.util.find_spec( |
148 | 147 | f".{module_name}", "klippy.plugins" |
149 | 148 | ) |
150 | | - entrypoints = importlib_metadata.entry_points( |
151 | | - group="kalico.plugins", name=module_name |
152 | | - ) |
153 | | - if entrypoints: |
| 149 | + entrypoints = util.find_entrypoints() |
| 150 | + if module_name in entrypoints: |
154 | 151 | entrypoint = entrypoints[module_name] |
| 152 | + metadata = util.entrypoint_metadata(entrypoint) |
155 | 153 | if extras_spec and not get_danger_options().allow_plugin_override: |
156 | 154 | raise self.config_error( |
157 | 155 | f"Module '{section}' found in both extras and " |
158 | | - f"installed plugin {entrypoint.dist.name} (v{entrypoint.dist.version})" |
| 156 | + f"installed plugin {metadata['name']} (v{metadata['version']})" |
159 | 157 | ) |
160 | 158 | logging.info( |
161 | | - f"Loading '{module_name}' from plugin {entrypoint.dist.name} ({entrypoint.dist.version})" |
| 159 | + f"Loading '{module_name}' from plugin {metadata['name']} (v{metadata['version']})" |
162 | 160 | ) |
163 | 161 | mod = entrypoint.load() |
164 | 162 | elif plugins_spec: |
@@ -558,10 +556,10 @@ def main(): |
558 | 556 | extra_git_desc += "\nRemote: %s" % (git_info["remote"]) |
559 | 557 | extra_git_desc += "\nTracked URL: %s" % (git_info["url"]) |
560 | 558 |
|
561 | | - plugins = importlib_metadata.entry_points(group="kalico.plugins") |
562 | | - for plugin in plugins: |
563 | | - extra_git_desc += f"\nPlugin {plugin.dist.name}=={plugin.dist.version}" |
564 | | - start_args["plugins"][plugin.dist.name] = plugin.dist.metadata.json |
| 559 | + for entrypoint in util.find_entrypoints().values(): |
| 560 | + metadata = util.entrypoint_metadata(entrypoint) |
| 561 | + extra_git_desc += f"\nPlugin {metadata['name']}=={metadata['version']}" |
| 562 | + start_args["plugins"][metadata["name"]] = metadata |
565 | 563 |
|
566 | 564 | start_args["software_version"] = git_vers |
567 | 565 | start_args["git_branch"] = git_info["branch"] |
|
0 commit comments