From 1004856abeb1f5a029dabf4f80a7aa8becbf4531 Mon Sep 17 00:00:00 2001 From: juga Date: Wed, 21 Oct 2020 12:58:17 +0000 Subject: [PATCH] Programatically obtain the package version Closes: PYADPT-96 --- src/pEp/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/pEp/__init__.py b/src/pEp/__init__.py index 0bc2c9e..58a6fc7 100644 --- a/src/pEp/__init__.py +++ b/src/pEp/__init__.py @@ -2,6 +2,12 @@ # This file is being exectued upon 'import pEp' # # __all__ could be used to limit the symbols exported when using from import * +from pkg_resources import DistributionNotFound, get_distribution + +try: + __version__ = get_distribution(__name__).version +except DistributionNotFound: + print("Package is not installed.") # Import all symbols EXCEPT the ones beginning with underscore into the current namespace