Skip to content

Commit 44f2139

Browse files
kbankrabben
andauthored
Move from pkg resources to importlib (#172)
* move to importlib * install/use importlib_metadata for py < 3.8 --------- Co-authored-by: Nick Krabbenhoeft <[email protected]>
1 parent da5656c commit 44f2139

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

bagit.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@
2121
from functools import partial
2222
from os.path import abspath, isdir, isfile, join
2323

24-
from pkg_resources import DistributionNotFound, get_distribution
24+
try:
25+
from importlib.metadata import version
26+
except ImportError:
27+
from importlib_metadata import version
2528

2629
try:
2730
from urllib.parse import urlparse
@@ -48,9 +51,8 @@ def find_locale_dir():
4851

4952
LOGGER = logging.getLogger(MODULE_NAME)
5053

51-
try:
52-
VERSION = get_distribution(MODULE_NAME).version
53-
except DistributionNotFound:
54+
VERSION = version(MODULE_NAME)
55+
if not VERSION:
5456
VERSION = "0.0.dev0"
5557

5658
PROJECT_URL = "https://github.com/LibraryOfCongress/bagit-python"

setup.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ def get_message_catalogs():
6262
platforms=["POSIX"],
6363
test_suite="test",
6464
setup_requires=["setuptools_scm"],
65+
install_requires=["importlib_metadata ; python_version < '3.8'"],
6566
tests_require=tests_require,
6667
classifiers=[
6768
"License :: Public Domain",

0 commit comments

Comments
 (0)