Skip to content

Commit

Permalink
Switch from pkg_resources (deprecated) to importlib (Python 3.8+) for…
Browse files Browse the repository at this point in the history
… version detection

Signed-off-by: Sergey Vasilyev <[email protected]>
  • Loading branch information
nolar committed Oct 15, 2023
1 parent 22445e5 commit 276bdaf
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions kopf/_cogs/helpers/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,12 @@
version: Optional[str] = None

try:
import pkg_resources
import importlib.metadata
except ImportError:
pass
else:
try:
name, *_ = __name__.split('.') # usually "kopf", unless renamed/forked.
dist: pkg_resources.Distribution = pkg_resources.get_distribution(name)
version = dist.version
version = importlib.metadata.version(name)
except Exception:
pass # installed as an egg, from git, etc.

0 comments on commit 276bdaf

Please sign in to comment.