diff --git a/bagit.py b/bagit.py index a27780c..9b55365 100755 --- a/bagit.py +++ b/bagit.py @@ -21,7 +21,10 @@ from functools import partial from os.path import abspath, isdir, isfile, join -from pkg_resources import DistributionNotFound, get_distribution +try: + from importlib.metadata import version +except ImportError: + from importlib_metadata import version try: from urllib.parse import urlparse @@ -48,9 +51,8 @@ def find_locale_dir(): LOGGER = logging.getLogger(MODULE_NAME) -try: - VERSION = get_distribution(MODULE_NAME).version -except DistributionNotFound: +VERSION = version(MODULE_NAME) +if not VERSION: VERSION = "0.0.dev0" PROJECT_URL = "https://github.com/LibraryOfCongress/bagit-python" diff --git a/setup.py b/setup.py index c51a55a..4bf8f5b 100644 --- a/setup.py +++ b/setup.py @@ -62,6 +62,7 @@ def get_message_catalogs(): platforms=["POSIX"], test_suite="test", setup_requires=["setuptools_scm"], + install_requires=["importlib_metadata ; python_version < '3.8'"], tests_require=tests_require, classifiers=[ "License :: Public Domain",