Skip to content

Commit

Permalink
Fix: pkg_resources is obsolete to get package version
Browse files Browse the repository at this point in the history
Solution: Use `importlib.metadata.version` instead.
  • Loading branch information
hoh committed Jun 13, 2024
1 parent 02490d1 commit fb83626
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions src/aleph/sdk/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,13 @@
from pkg_resources import DistributionNotFound, get_distribution

from importlib.metadata import version, PackageNotFoundError
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):
Expand Down

0 comments on commit fb83626

Please sign in to comment.