From 221ec97e0ffc8f4a591c45a399a7371adf99c2a5 Mon Sep 17 00:00:00 2001 From: "Michael R. Crusoe" Date: Thu, 23 Nov 2023 15:20:46 +0100 Subject: [PATCH 1/2] Only require importlib_metadata for Python<3.8 --- bdbag/__init__.py | 5 ++++- bdbag/bdbag_config.py | 6 +++++- setup.py | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/bdbag/__init__.py b/bdbag/__init__.py index abfe3a9..691ec7b 100644 --- a/bdbag/__init__.py +++ b/bdbag/__init__.py @@ -22,7 +22,10 @@ import shutil from datetime import datetime from distutils.util import strtobool -from importlib_metadata import distribution, PackageNotFoundError +if sys.version_info >= (3,8): + from importlib.metadata import distribution, PackageNotFoundError +else + from importlib_metadata import distribution, PackageNotFoundError logger = logging.getLogger(__name__) diff --git a/bdbag/bdbag_config.py b/bdbag/bdbag_config.py index b993ff2..66a4c30 100644 --- a/bdbag/bdbag_config.py +++ b/bdbag/bdbag_config.py @@ -14,12 +14,16 @@ # limitations under the License. # import os +import sys import errno import logging import json from collections import OrderedDict from packaging.version import parse as parse_version -from importlib_metadata import distribution, PackageNotFoundError +if sys.version_info >= (3,8): + from importlib.metadata import distribution, PackageNotFoundError +else: + from importlib_metadata import distribution, PackageNotFoundError from bdbag import get_typed_exception, safe_move, \ DEFAULT_CONFIG_PATH, BAG_PROFILE_TAG, BDBAG_PROFILE_ID, VERSION, __version__ from bdbag.fetch import Megabyte diff --git a/setup.py b/setup.py index 78feb72..a2bec3b 100644 --- a/setup.py +++ b/setup.py @@ -63,7 +63,7 @@ 'tzlocal', 'certifi', 'packaging', - 'importlib-metadata', + 'importlib_metadata;python_version<"3.8"', 'requests>=2.7.0', 'setuptools_scm<6.0', # for bagit which does not properly include it in install_requires 'bagit==1.8.1', From f187cf9d832300fc9210e7ab9ca8d56de1e71fa5 Mon Sep 17 00:00:00 2001 From: "Michael R. Crusoe" <1330696+mr-c@users.noreply.github.com> Date: Fri, 1 Dec 2023 08:53:41 +0100 Subject: [PATCH 2/2] Update __init__.py --- bdbag/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bdbag/__init__.py b/bdbag/__init__.py index 691ec7b..785b281 100644 --- a/bdbag/__init__.py +++ b/bdbag/__init__.py @@ -24,7 +24,7 @@ from distutils.util import strtobool if sys.version_info >= (3,8): from importlib.metadata import distribution, PackageNotFoundError -else +else: from importlib_metadata import distribution, PackageNotFoundError logger = logging.getLogger(__name__)