diff --git a/setup.py b/setup.py
index 41a2c194dfc7f5cc9342429fb9461daa2cc4d9f2..2b040aa0cdea75e68a005ac59f55124b0ebb144b 100755
--- a/setup.py
+++ b/setup.py
@@ -4,6 +4,7 @@
 #
 """linkahead"""
 import os
+import re
 import subprocess
 import sys
 
@@ -96,6 +97,7 @@ def get_version_info():
     FULLVERSION = VERSION
 
     # Magic which is only really needed in the pipelines. Therefore: a lot of dark pipeline magic.
+    GIT_REVISION = "Unknown"
     if os.path.exists('.git'):
         GIT_REVISION = git_version()
     elif os.path.exists('linkahead_pylib_commit'):
@@ -103,14 +105,13 @@ def get_version_info():
             GIT_REVISION = f.read().strip()
     elif os.path.exists('src/linkahead/version.py'):
         # must be a source distribution, use existing version file
-        try:
-            from linkahead.version import git_revision as GIT_REVISION
-        except ImportError:
-            raise ImportError("Unable to import git_revision. Try removing "
-                              "src/linkahead/version.py and the build directory "
-                              "before building.")
-    else:
-        GIT_REVISION = "Unknown"
+        with open('src/linkahead/version.py') as fi:
+            rev_pattern = re.compile(r"^git_revision = '(?P<rev>.*)'$")
+            for line in fi.readlines():
+                match = rev_pattern.match(line)
+                if match is not None:
+                    GIT_REVISION = match.group('rev')
+                    break
 
     if not ISRELEASED:
         FULLVERSION += '.dev0+' + GIT_REVISION[:7]