From b4b7e315f1c6a2d3c009c98b5cc18ecb8fcb7a8f Mon Sep 17 00:00:00 2001
From: "Zooko O'Whielacronx zooko@zooko.com" <zooko@zooko.com>
Date: Mon, 4 Jun 2007 17:16:52 +0530
Subject: [PATCH] zfec: autogenerate version numbers from darcs history

darcs-hash:ad97ae58fdd48086d85300ee61d15c81ff2ededf
---
 zfec/setup.py               | 19 ++++++++++++++++++-
 zfec/zfec/__init__.py       | 16 +++++++---------
 zfec/zfec/cmdline_zfec.py   |  2 +-
 zfec/zfec/test/test_util.py |  2 +-
 4 files changed, 27 insertions(+), 12 deletions(-)

diff --git a/zfec/setup.py b/zfec/setup.py
index a8c08d8..7c39d09 100755
--- a/zfec/setup.py
+++ b/zfec/setup.py
@@ -71,8 +71,25 @@ trove_classifiers=[
     "Topic :: System :: Archiving", 
     ]
 
+import re
+VERSIONFILE = "zfec/_version.py"
+verstr = "unknown"
+VSRE = re.compile("^verstr = ['\"]([^'\"]*)['\"]", re.M)
+try:
+    verstrline = open(VERSIONFILE, "rt").read()
+except EnvironmentError:
+    pass # Okay, there is no version file.
+else:
+    mo = VSRE.search(verstrline)
+    if mo:
+        verstr = mo.group(1)
+    else:
+        print "unable to find version in %s" % (VERSIONFILE,)
+        raise RuntimeError("if %s.py exists, it must be well-formed" % (VERSIONFILE,))
+
 setup(name='zfec',
-      version='1.0.0',
+      install_requires=['pyutil>=1.0.0',],
+      version=verstr,
       description='a fast erasure code with command-line, C, and Python interfaces',
       long_description='Fast, portable, programmable erasure coding a.k.a. "forward error correction": the generation of redundant blocks of information such that if some blocks are lost then the original data can be recovered from the remaining blocks.',
       author='Zooko O\'Whielacronx',
diff --git a/zfec/zfec/__init__.py b/zfec/zfec/__init__.py
index 279c226..a445dcc 100644
--- a/zfec/zfec/__init__.py
+++ b/zfec/zfec/__init__.py
@@ -6,15 +6,13 @@ maintainer web site: U{http://allmydata.com/source/zfec}
 zfec web site: U{http://allmydata.com/source/zfec}
 """
 
-from util.version import Version
-
-# For an explanation of what the parts of the version string mean,
-# please see pyutil.version.
-__version__ = Version("1.0.0b3-0-STABLE")
-
-# Please put a URL or other note here which shows where to get the branch of
-# development from which this version grew.
-__sources__ = ["http://allmydata.org/source/zfec",]
+__version__ = "unknown"
+try:
+    from _version import __version__
+except ImportError:
+    # we're running in a tree that hasn't run make-version.py, so we don't
+    # know what our version is. This should not happen very often.
+    pass
 
 from _fec import Encoder, Decoder, Error
 import filefec, cmdline_zfec, cmdline_zunfec
diff --git a/zfec/zfec/cmdline_zfec.py b/zfec/zfec/cmdline_zfec.py
index b0fa1a3..24d98de 100755
--- a/zfec/zfec/cmdline_zfec.py
+++ b/zfec/zfec/cmdline_zfec.py
@@ -61,7 +61,7 @@ def main():
 # Author: Zooko Wilcox-O'Hearn
 # 
 # This file is part of zfec.
-# 
+
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by the Free
 # Software Foundation; either version 2 of the License, or (at your option)
diff --git a/zfec/zfec/test/test_util.py b/zfec/zfec/test/test_util.py
index 18ad3c7..a8b183c 100644
--- a/zfec/zfec/test/test_util.py
+++ b/zfec/zfec/test/test_util.py
@@ -1,5 +1,5 @@
 
-from twisted.trial import unittest
+import unittest
 
 from zfec.util import mathutil
 
-- 
2.45.2