diff --git a/pyfstat/__init__.py b/pyfstat/__init__.py
index e81fdb0ed13875a1d73e9e1bf38413692d128e3c..9036370f0e8a8472fedbc476d2249f61e934430c 100644
--- a/pyfstat/__init__.py
+++ b/pyfstat/__init__.py
@@ -26,3 +26,7 @@ from .grid_based_searches import (
     SliceGridSearch,
     TransientGridSearch,
 )
+
+
+from .helper_functions import get_version_information
+__version__ = get_version_information()
diff --git a/pyfstat/helper_functions.py b/pyfstat/helper_functions.py
index bddaa9ba0431f3ff7cc88684359cdedd2b39a09a..063876a01a1e90a047dd7dc90da88c28c457ac36 100644
--- a/pyfstat/helper_functions.py
+++ b/pyfstat/helper_functions.py
@@ -390,3 +390,13 @@ def match_commandlines(cl1, cl2, be_strict_about_full_executable_path=False):
         cl2s[0] = os.path.basename(cl2s[0])
     unmatched = np.setxor1d(cl1s, cl2s)
     return len(unmatched) == 0
+
+
+def get_version_information():
+    version_file = os.path.join(
+        os.path.dirname(os.path.dirname(__file__)), 'pyfstat/.version')
+    try:
+        with open(version_file, 'r') as f:
+            return f.readline().rstrip()
+    except EnvironmentError:
+        print("No version information file '.version' found")
diff --git a/setup.py b/setup.py
index 69b60fd63fd6d99f3e994782bcd3aa7fe0c9f7ef..65bd30650f060ddeaefa715b89b6c1464026514c 100644
--- a/setup.py
+++ b/setup.py
@@ -3,6 +3,46 @@
 from setuptools import setup, find_packages
 from os import path
 import sys
+import subprocess
+
+
+def write_version_file(version):
+    """ Writes a file with version information to be used at run time
+
+    Parameters
+    ----------
+    version: str
+        A string containing the current version information
+
+    Returns
+    -------
+    version_file: str
+        A path to the version file
+
+    """
+    try:
+        git_log = subprocess.check_output(
+            ['git', 'log', '-1', '--pretty=%h %ai']).decode('utf-8')
+        git_diff = (subprocess.check_output(['git', 'diff', '.']) +
+                    subprocess.check_output(
+                        ['git', 'diff', '--cached', '.'])).decode('utf-8')
+        if git_diff == '':
+            git_status = '(CLEAN) ' + git_log
+        else:
+            git_status = '(UNCLEAN) ' + git_log
+    except Exception as e:
+        print("Unable to obtain git version information, exception: {}"
+              .format(e))
+        git_status = ''
+
+    version_file = '.version'
+    if path.isfile(version_file) is False:
+        with open('pyfstat/' + version_file, 'w+') as f:
+            f.write('{}: {}'.format(version, git_status))
+        print('Done', version_file, version, git_status)
+
+    return version_file
+
 
 # check python version
 min_python_version = (3, 5, 0)  # (major,minor,micro)
@@ -21,9 +61,12 @@ here = path.abspath(path.dirname(__file__))
 with open(path.join(here, "README.md"), encoding="utf-8") as f:
     long_description = f.read()
 
+VERSION = '1.3'
+version_file = write_version_file(VERSION)
+
 setup(
     name="PyFstat",
-    version="1.3",
+    version=VERSION,
     author="Gregory Ashton, David Keitel, Reinhard Prix",
     author_email="gregory.ashton@ligo.org",
     license="MIT",
@@ -36,6 +79,7 @@ setup(
         "pyfstat": [
             "pyCUDAkernels/cudaTransientFstatExpWindow.cu",
             "pyCUDAkernels/cudaTransientFstatRectWindow.cu",
+            version_file
         ]
     },
     python_requires=">=%s.%s.%s" % min_python_version[:3],