From f62d04b3ea2c5baeb36e0fff63e38f08b876520f Mon Sep 17 00:00:00 2001 From: Hugo Herter Date: Thu, 13 Jun 2024 16:07:45 +0200 Subject: [PATCH] Fix: pkg_resources is obsolete to get package version Solution: Use `importlib.metadata.version` instead. --- src/aleph/sdk/__init__.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/aleph/sdk/__init__.py b/src/aleph/sdk/__init__.py index a3ecc693..358ddd96 100644 --- a/src/aleph/sdk/__init__.py +++ b/src/aleph/sdk/__init__.py @@ -1,17 +1,14 @@ -from pkg_resources import DistributionNotFound, get_distribution +from importlib.metadata import PackageNotFoundError, version from aleph.sdk.client import AlephHttpClient, AuthenticatedAlephHttpClient try: # Change here if project is renamed and does not equal the package name - dist_name = "aleph-sdk-python" - __version__ = get_distribution(dist_name).version -except DistributionNotFound: + __version__ = version("aleph-sdk-python") +except PackageNotFoundError: __version__ = "unknown" -finally: - del get_distribution, DistributionNotFound -__all__ = ["AlephHttpClient", "AuthenticatedAlephHttpClient"] +__all__ = ["__version__", "AlephHttpClient", "AuthenticatedAlephHttpClient"] def __getattr__(name):