diff --git a/pygenn/__init__.py b/pygenn/__init__.py index 9f3327786a..00fb9ef413 100644 --- a/pygenn/__init__.py +++ b/pygenn/__init__.py @@ -1,3 +1,13 @@ -# Import pygenn interface +# python imports +import sys + +# pygenn interface from .genn_groups import SynapseGroup, NeuronGroup, CurrentSource from .genn_model import GeNNModel + +if sys.version_info >= (3, 8): + from importlib import metadata +else: + import importlib_metadata as metadata + +__version__ = metadata.version("pygenn") \ No newline at end of file diff --git a/setup.py b/setup.py index 8086d48ef7..ac971b0cfa 100644 --- a/setup.py +++ b/setup.py @@ -177,8 +177,12 @@ ext_modules.append(Extension("_" + namespace + "Backend", ["pygenn/genn_wrapper/generated/" + namespace + "Backend.i"], **backend_extension_kwargs)) +# Read version from txt file +with open(os.path.join(genn_path, "version.txt")) as version_file: + version = version_file.read().strip() + setup(name = "pygenn", - version = "0.4.6", + version = version, packages = find_packages(), package_data={"pygenn": package_data}, @@ -189,6 +193,7 @@ ext_modules=ext_modules, # Requirements - install_requires=["numpy>=1.17", "six", "deprecated", "psutil"], + install_requires=["numpy>=1.17", "six", "deprecated", "psutil", + "importlib-metadata>=1.0;python_version<'3.8'"], zip_safe=False, # Partly for performance reasons )