Skip to content

Commit

Permalink
scuba: Use importlib.metadata over pkg_resources
Browse files Browse the repository at this point in the history
pkg_resources is deprecated.

Fixes #245
  • Loading branch information
JonathonReinhart committed Jan 3, 2024
1 parent 3dc54d6 commit adff272
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
3 changes: 2 additions & 1 deletion VERSIONING.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,5 @@ versioning scheme. Consider a base version of `1.2.3`:
created via `python setup.py sdist`. In this case, the version comes from
the egg info generated by setuptools.

In any case, when Scuba is installed, the version comes from `pkg_resources`.
In any case, when Scuba is installed, the version comes from
`importlib.metadata`.
6 changes: 3 additions & 3 deletions scuba/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ def get_version() -> str:
# Package resource
# Otherwise, we're either installed (e.g. via pip), or running from
# an 'sdist' source distribution, and have a local PKG_INFO file.
import pkg_resources
import importlib.metadata

try:
return pkg_resources.get_distribution(DIST_SPEC).version
except pkg_resources.DistributionNotFound:
return importlib.metadata.version(DIST_SPEC)
except importlib.metadata.PackageNotFoundError:
pass

# This shouldn't be able to happen
Expand Down

0 comments on commit adff272

Please sign in to comment.