diff options
author | Mario Mulansky <mario.mulansky@gmx.net> | 2015-04-30 17:23:06 +0200 |
---|---|---|
committer | Mario Mulansky <mario.mulansky@gmx.net> | 2015-04-30 17:23:06 +0200 |
commit | 7757dc01e2d6020e0f6d6e44afdb734e61ef3c9c (patch) | |
tree | 1b0004f37cbd2ac5ad78b7f8fca5f28450f21690 /pyspike/__init__.py | |
parent | ec9850a12818d9c91d73372dccf83776449be5cc (diff) |
addresses #5 - added __version__ property
Diffstat (limited to 'pyspike/__init__.py')
-rw-r--r-- | pyspike/__init__.py | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/pyspike/__init__.py b/pyspike/__init__.py index a5f9f0a..3e836bd 100644 --- a/pyspike/__init__.py +++ b/pyspike/__init__.py @@ -23,3 +23,22 @@ from psth import psth from spikes import load_spike_trains_from_txt, spike_train_from_string, \ merge_spike_trains, generate_poisson_spikes + + +# define the __version__ following +# http://stackoverflow.com/questions/17583443 +from pkg_resources import get_distribution, DistributionNotFound +import os.path + +try: + _dist = get_distribution('pyspike') + # Normalize case for Windows systems + dist_loc = os.path.normcase(_dist.location) + here = os.path.normcase(__file__) + if not here.startswith(os.path.join(dist_loc, 'pyspike')): + # not installed, but there is another version that *is* + raise DistributionNotFound +except DistributionNotFound: + __version__ = 'Please install this project with setup.py' +else: + __version__ = _dist.version |