Skip to content

Commit

Permalink
Switch to importlib-metadata to drop deprecated pkg_resources
Browse files Browse the repository at this point in the history
According to https://setuptools.pypa.io/en/latest/pkg_resources.html,
pkg_resources has been deprecated and importlib-metadata is recommended.
`DistributionNotFound` only can be thrown from `find_plugins()` which is
not used by ia. Tested with plugin
https://github.com/JesseWeinstein/ia_recent.

Closes: #613
  • Loading branch information
FantasqueX committed Jan 11, 2024
1 parent 6e23216 commit 7f882e7
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
6 changes: 3 additions & 3 deletions internetarchive/cli/ia.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
import sys

from docopt import docopt, printable_usage
from pkg_resources import DistributionNotFound, iter_entry_points
from importlib.metadata import entry_points
from schema import Or, Schema, SchemaError # type: ignore[import]

from internetarchive import __version__
Expand Down Expand Up @@ -97,11 +97,11 @@ def load_ia_module(cmd: str):
return __import__(_module, fromlist=['internetarchive.cli'])
else:
_module = f'ia_{cmd}'
for ep in iter_entry_points('internetarchive.cli.plugins'):
for ep in entry_points(group='internetarchive.cli.plugins'):
if ep.name == _module:
return ep.load()
raise ImportError
except (ImportError, DistributionNotFound):
except (ImportError):
print(f"error: '{cmd}' is not an ia command! See 'ia help'",
file=sys.stderr)
matches = '\t'.join(difflib.get_close_matches(cmd, cmd_aliases.values()))
Expand Down
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ packages =
internetarchive.cli
install_requires =
docopt>=0.6.0,<0.7.0
importlib-metadata; python_version <= 3.7
jsonpatch>=0.4
requests>=2.25.0,<3.0.0
schema>=0.4.0
Expand Down

0 comments on commit 7f882e7

Please sign in to comment.