summaryrefslogtreecommitdiff
path: root/pyspike/__init__.py
diff options
context:
space:
mode:
Diffstat (limited to 'pyspike/__init__.py')
-rw-r--r--pyspike/__init__.py19
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