From 40e1c4be71e1dfb71c8e14a2f8354a23c44f6143 Mon Sep 17 00:00:00 2001
From: Zooko O'Whielacronx <zooko@zooko.com>
Date: Tue, 1 May 2007 13:23:15 -0700
Subject: [PATCH] grand unified version numbers Now the allmydata python
 package, the setup.py script, and the debian packages all get their tahoe
 version number from the same place.

---
 GNUmakefile               | 8 ++++----
 setup.py                  | 8 +++++++-
 src/allmydata/__init__.py | 5 ++++-
 3 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/GNUmakefile b/GNUmakefile
index 1ee9cd79..ba01374e 100644
--- a/GNUmakefile
+++ b/GNUmakefile
@@ -175,13 +175,13 @@ create_dirs:
 	mkdir -p client-basedir/storage
 	mkdir -p client-basedir2/storage
 
-DEBVER=`head -1 debian/changelog | sed -e 's/^[^(]*(\([^)]*\)).*$$/\1/' | sed -e 's/^\([0-9]\+\.[0-9]\+\.[0-9]\+\).*$$/\1/'`
-DEBSTRING=$(DEBVER)-T`date +%s`
+VER=$(shell python -c "import os,re;print re.search(\"verstr=['\\\"](.*?)['\\\"]\", open(os.path.join('src', 'allmydata', '__init__.py')).readline()).group(1)")
+DEBSTRING=$(VER)-T`date +%s`
 DEBCOMMENTS="'make deb' build"
 
 show:
-	echo $(DEBVER)
-	echo $(DEBSTRING)
+	@echo $(VER)
+	@echo $(DEBSTRING)
 
 .PHONY: setup-dapper setup-sid setup-edgy setup-feisty
 .PHONY: deb-dapper deb-sid deb-edgy deb-feisty
diff --git a/setup.py b/setup.py
index 2effe799..c932a3df 100644
--- a/setup.py
+++ b/setup.py
@@ -55,8 +55,14 @@ trove_classifiers=[
     "Topic :: System :: Archiving", 
     ]
 
+import re
+VSRE=re.compile("verstr=['\"]([^'\"]*)['\"]")
+verstrline=open("src/allmydata/__init__.py").readline()
+mo = VSRE.search(verstrline)
+verstr = mo.group(1)
+
 setup(name='allmydata-tahoe',
-      version='0.2.0b1',
+      version=verstr,
       description='secure, distributed storage grid',
       long_description="""Welcome to the AllMyData "tahoe" project. This project implements a
 secure, distributed, fault-tolerant storage grid.
diff --git a/src/allmydata/__init__.py b/src/allmydata/__init__.py
index 2baf0b53..25df41fe 100644
--- a/src/allmydata/__init__.py
+++ b/src/allmydata/__init__.py
@@ -1,3 +1,6 @@
+verstr="0.2.0b1-0-UNSTABLE"
+# The line is placed above so that it can be easily read by build scripts.
+
 """
 Decentralized storage grid.
 
@@ -10,7 +13,7 @@ from util.version import Version
 
 # For an explanation of what the parts of the version string mean,
 # please see pyutil.version.
-__version__ = Version("0.2.0b1-0-UNSTABLE")
+__version__ = Version(verstr)
 
 # Please put a URL or other note here which shows where to get the branch of
 # development from which this version grew.
-- 
2.45.2