From a58d8d75defeec0e5e96756e2716b4042ec5a6d1 Mon Sep 17 00:00:00 2001 From: Ruben Verweij Date: Fri, 23 Apr 2021 12:53:29 +0200 Subject: [PATCH] Fix #42: read version number from setup.py --- nd2reader/__init__.py | 10 +++++++++- setup.py | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/nd2reader/__init__.py b/nd2reader/__init__.py index 8354a47..3941461 100644 --- a/nd2reader/__init__.py +++ b/nd2reader/__init__.py @@ -2,4 +2,12 @@ from os import path from nd2reader.reader import ND2Reader from nd2reader.legacy import Nd2 -__version__ = '3.2.3' +try: + import importlib.metadata as importlib_metadata +except ModuleNotFoundError: + import importlib_metadata + +try: + __version__ = importlib_metadata.version(__name__) +except: + print('Unable to read version number') diff --git a/setup.py b/setup.py index 0ade4f4..73f7bf7 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,6 @@ from setuptools import setup -from nd2reader import __version__ as VERSION + +VERSION = '3.2.3' if __name__ == '__main__': setup(