From 1dd702ad011236ea684924877c571d105759c234 Mon Sep 17 00:00:00 2001 From: Florian Wahl <41266220+wahlflo@users.noreply.github.com> Date: Mon, 13 May 2024 22:27:54 +0200 Subject: [PATCH] replace deprecated pkg_resources API with importlib.metadata (#29) --- src/ewmh_m2m/__init__.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/ewmh_m2m/__init__.py b/src/ewmh_m2m/__init__.py index c99a72a..21aa09e 100644 --- a/src/ewmh_m2m/__init__.py +++ b/src/ewmh_m2m/__init__.py @@ -1,11 +1,10 @@ # -*- coding: utf-8 -*- -from pkg_resources import get_distribution, DistributionNotFound +import importlib.metadata try: # Change here if project is renamed and does not equal the package name - dist_name = __name__ - __version__ = get_distribution(dist_name).version -except DistributionNotFound: + __version__ = importlib.metadata.version(__name__) +except importlib.metadata.PackageNotFoundError: __version__ = 'unknown' finally: - del get_distribution, DistributionNotFound + del importlib.metadata