From a3a2eff6a1848711abf0a8897a5414b91497ef2f Mon Sep 17 00:00:00 2001 From: Georg Pfuetzenreuter Date: Sat, 10 Feb 2024 19:54:24 +0100 Subject: [PATCH] Migrate away from pkg_resources Using pkg_resources as an API is deprecated. Migrate functionality to the importlib equivalent. This repairs "No module named 'pkg_resources'" on modern distributions. Signed-off-by: Georg Pfuetzenreuter --- pepper/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pepper/__init__.py b/pepper/__init__.py index 267c5e2..fe20b91 100644 --- a/pepper/__init__.py +++ b/pepper/__init__.py @@ -1,15 +1,15 @@ ''' Pepper is a CLI front-end to salt-api ''' -import pkg_resources +from importlib.metadata import PackageNotFoundError, version from pepper.libpepper import Pepper, PepperException __all__ = ('__version__', 'Pepper', 'PepperException') try: - __version__ = pkg_resources.get_distribution('salt_pepper').version -except pkg_resources.DistributionNotFound: + __version__ = version('salt_pepper') +except PackageNotFoundError: # package is not installed __version__ = None