From 18f01bed7eb7104bc2b8cf3f84ddacb176acefb9 Mon Sep 17 00:00:00 2001 From: juga Date: Wed, 21 Oct 2020 13:15:39 +0000 Subject: [PATCH] Programatically obtain package version Closes PYADPT-96 --- src/pEp/__init__.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pEp/__init__.py b/src/pEp/__init__.py index 0bc2c9e..ab29698 100644 --- a/src/pEp/__init__.py +++ b/src/pEp/__init__.py @@ -2,7 +2,7 @@ # 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 # Import all symbols EXCEPT the ones beginning with underscore into the current namespace from native_pEp import * @@ -11,6 +11,10 @@ from native_pEp import * # import the module import native_pEp +try: + __version__ = get_distribution(__name__).version +except DistributionNotFound: + print("Package is not installed.") # Executed on module import def init():