diff --git a/setup.py b/setup.py
index 5d5c92f3573ce1c470dd59755cbfb4912c2e7d12..de90ebaf4783503281ff2b2cea3005f90a29de58 100755
--- a/setup.py
+++ b/setup.py
@@ -97,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'):
@@ -105,14 +106,12 @@ def get_version_info():
     elif os.path.exists('src/linkahead/version.py'):
         # must be a source distribution, use existing version file
         with open('src/linkahead/version.py') as fi:
+            rev_pattern = re.compile(r"^git_revision = '(?P<rev>.*)'$")
             for line in fi.readlines():
-                match = re.match(r"^git_revision = (?P<rev>.*)$", line)
-
+                match = rev_pattern.match(line)
                 if match is not None:
                     GIT_REVISION = match.group('rev')
-
-    else:
-        GIT_REVISION = "Unknown"
+                    break
 
     if not ISRELEASED:
         FULLVERSION += '.dev0+' + GIT_REVISION[:7]