From 2eeb8ee6f505775ef89dd6e3221cc2f1ed17e9bc Mon Sep 17 00:00:00 2001
From: Daira Hopwood <daira@jacaranda.org>
Date: Fri, 21 Nov 2014 08:38:37 +0000
Subject: [PATCH] setup.py: set distribution.metadata.version from _version.py
 if we couldn't find it from git. This simplifies reporting when we don't have
 the version. Also print the normalized version. refs #2340

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
---
 setup.py | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/setup.py b/setup.py
index 1d165237..83f8b75c 100644
--- a/setup.py
+++ b/setup.py
@@ -351,13 +351,19 @@ class UpdateVersion(Command):
     def finalize_options(self):
         pass
     def run(self):
+        global version
+        verstr = version
         if os.path.isdir(os.path.join(basedir, ".git")):
             verstr = self.try_from_git()
-        else:
-            print("no version-control data found, leaving _version.py alone")
-            return
+
         if verstr:
             self.distribution.metadata.version = verstr
+        else:
+            print("""\
+********************************************************************
+Warning: no version information found. This may cause tests to fail.
+********************************************************************
+""")
 
     def try_from_git(self):
         versions = versions_from_git("allmydata-tahoe-")
@@ -371,7 +377,7 @@ class UpdateVersion(Command):
                       "branch": versions["branch"],
                     })
             f.close()
-            print("git-version: wrote '%s' into '%s'" % (versions["version"], VERSION_PY_FILENAME))
+            print("Wrote normalized version %r into '%s'" % (versions["normalized"], VERSION_PY_FILENAME))
 
         return versions.get("normalized", None)
 
-- 
2.45.2