Skip to content

Commit c2e77ca

Browse files
authored
Merge pull request #41 from ceph/wip-drop-pkg-resources
cli: drop pkg_resources import
2 parents 76e1c90 + dfa414b commit c2e77ca

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

bootstrap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set -e
44
if command -v lsb_release >/dev/null 2>&1; then
55
case "$(lsb_release --id --short)" in
66
Ubuntu|Debian)
7-
for package in python-virtualenv python-dev libxml2-dev libxslt1-dev python-libvirt genisoimage; do
7+
for package in python3-venv python3-dev libxml2-dev libxslt1-dev python3-libvirt genisoimage pkg-config libvirt-dev gcc; do
88
if [ "$(dpkg --status -- $package 2>/dev/null|sed -n 's/^Status: //p')" != "install ok installed" ]; then
99
# add a space after old values
1010
missing="${missing:+$missing }$package"

downburst/cli.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import argparse
22
import logging
3-
import pkg_resources
43
import sys
54

5+
from importlib import metadata as meta
6+
67
from . import exc
78

89

@@ -32,7 +33,15 @@ def parse_args():
3233
metavar='COMMAND',
3334
help='description',
3435
)
35-
for ep in pkg_resources.iter_entry_points('downburst.cli'):
36+
m = meta.entry_points()
37+
if type(m) is meta.EntryPoints:
38+
# python >=3.12 entry_points() returns metadata.EntryPoints
39+
eps = (ep for ep in m if ep.group == 'downburst.cli')
40+
else:
41+
# python <=3.11 entry_points() returns metadata.SelectableGroups
42+
43+
eps = (ep for ep in m.get('downburst.cli',[]))
44+
for ep in eps:
3645
fn = ep.load()
3746
p = sub.add_parser(ep.name, help=fn.__doc__)
3847
# ugly kludge but i really want to have a nice way to access

0 commit comments

Comments
 (0)