summaryrefslogtreecommitdiff
path: root/cmd2/__init__.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2020-07-12 19:00:54 -0400
committerGitHub <noreply@github.com>2020-07-12 19:00:54 -0400
commitaeacd50d8e397f08e928bd412ecac698a051d11e (patch)
treee541266f1a89ce0619dbe7645ee7d964d8848945 /cmd2/__init__.py
parent6e19fb191dc0dd82416a9e9cc0b8e4a0ab5f200c (diff)
parent859d45bf8f7254858fbfb6167fe073479e712cfd (diff)
downloadcmd2-git-aeacd50d8e397f08e928bd412ecac698a051d11e.tar.gz
Merge pull request #953 from dhellmann/drop-pkg-resources
replace pkg_resources with importlib.metadata
Diffstat (limited to 'cmd2/__init__.py')
-rw-r--r--cmd2/__init__.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/cmd2/__init__.py b/cmd2/__init__.py
index d49427f2..8c07fb80 100644
--- a/cmd2/__init__.py
+++ b/cmd2/__init__.py
@@ -3,10 +3,15 @@
# flake8: noqa F401
"""This simply imports certain things for backwards compatibility."""
-from pkg_resources import get_distribution, DistributionNotFound
try:
- __version__ = get_distribution(__name__).version
-except DistributionNotFound:
+ # For python 3.8 and later
+ import importlib.metadata as importlib_metadata
+except ImportError:
+ # For everyone else
+ import importlib_metadata
+try:
+ __version__ = importlib_metadata.version(__name__)
+except importlib_metadata.PackageNotFoundError:
# package is not installed
pass