Skip to content

Commit

Permalink
Fix for entry_points where python < 3.10
Browse files Browse the repository at this point in the history
python 3.10 has importlib_metadata.entry_points(group) parameter
it seems that less than 3.10 doesn't.  this patch test for
python version to see how to get the entry point groups.
  • Loading branch information
hemna committed Apr 21, 2024
1 parent 8e0de9c commit fa9ff7d
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion aprsd/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,25 @@ def check_version(ctx):
def sample_config(ctx):
"""Generate a sample Config file from aprsd and all installed plugins."""

def _get_selected_entry_points():
import sys
if sys.version_info < (3,10):
all = imp.entry_points()
selected = []
if "oslo.config.opts" in all:
for x in all["oslo.config.opts"]:
if x.group == "oslo.config.opts":
selected.append(x)
else:
selected = imp.entry_points(group="oslo.config.opts")

return selected

def get_namespaces():
args = []

selected = imp.entry_points(group="oslo.config.opts")
# selected = imp.entry_points(group="oslo.config.opts")
selected = _get_selected_entry_points()
for entry in selected:
if "aprsd" in entry.name:
args.append("--namespace")
Expand Down

0 comments on commit fa9ff7d

Please sign in to comment.