Skip to content

Commit f62d04b

Browse files
committed
Fix: pkg_resources is obsolete to get package version
Solution: Use `importlib.metadata.version` instead.
1 parent 02490d1 commit f62d04b

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

src/aleph/sdk/__init__.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,14 @@
1-
from pkg_resources import DistributionNotFound, get_distribution
1+
from importlib.metadata import PackageNotFoundError, version
22

33
from aleph.sdk.client import AlephHttpClient, AuthenticatedAlephHttpClient
44

55
try:
66
# Change here if project is renamed and does not equal the package name
7-
dist_name = "aleph-sdk-python"
8-
__version__ = get_distribution(dist_name).version
9-
except DistributionNotFound:
7+
__version__ = version("aleph-sdk-python")
8+
except PackageNotFoundError:
109
__version__ = "unknown"
11-
finally:
12-
del get_distribution, DistributionNotFound
1310

14-
__all__ = ["AlephHttpClient", "AuthenticatedAlephHttpClient"]
11+
__all__ = ["__version__", "AlephHttpClient", "AuthenticatedAlephHttpClient"]
1512

1613

1714
def __getattr__(name):

0 commit comments

Comments
 (0)