From 2755f28e7611882483b36acfa44347d555f8ef2d Mon Sep 17 00:00:00 2001
From: Zooko O'Whielacronx <zooko@zooko.com>
Date: Mon, 31 Dec 2007 23:28:31 -0700
Subject: [PATCH] setup: use darcsver instead of pyutil for darcsver, use
 setup.py plugin instead of executable for darcsver This hopefully fixes the
 deb builders.

---
 Makefile |  9 +++------
 setup.py | 25 ++++++++++++++++---------
 2 files changed, 19 insertions(+), 15 deletions(-)

diff --git a/Makefile b/Makefile
index 23d8aea9..012ffde0 100644
--- a/Makefile
+++ b/Makefile
@@ -62,14 +62,11 @@ PP=PYTHONPATH="$(SRCPATH)$(PATHSEP)$(PYTHONPATH)$(PATHSEP)$(EGGSPATH)"
 
 .PHONY: make-version build
 
-# The 'darcsver' executable comes in the 'pyutil' package:
-# http://pypi.python.org/pypi/pyutil It is necessary only if you want to
+# The 'darcsver' setup.py command comes in the 'darcsver' package:
+# http://pypi.python.org/pypi/darcsver It is necessary only if you want to
 # automatically produce a new _version.py file from the current darcs history.
-# N.B.: the first argument to darcsver is used to find darcs tags that represent
-# released versions, so it needs to match whatever release conventions are in
-# use.
 make-version:
-	darcsver "allmydata-tahoe" "src/allmydata/_version.py"
+	$(PYTHON) ./setup.py darcsver
 
 .built:
 	$(MAKE) build
diff --git a/setup.py b/setup.py
index 6f946cf6..50dcf152 100644
--- a/setup.py
+++ b/setup.py
@@ -77,14 +77,6 @@ trove_classifiers=[
     ]
 
 
-# Build _version.py before trying to extract a version from it. If we aren't
-# running from a darcs checkout, this will leave any pre-existing _version.py
-# alone.
-try:
-    (cin, cout, cerr,) = os.popen3("darcsver --quiet allmydata-tahoe src/allmydata/_version.py")
-    print cout.read()
-except Exception, le:
-    pass
 VERSIONFILE = "src/allmydata/_version.py"
 verstr = "unknown"
 VSRE = re.compile("^verstr = ['\"]([^'\"]*)['\"]", re.M)
@@ -108,6 +100,21 @@ The basic idea is that the data in this storage grid is spread over all
 participating nodes, using an algorithm that can recover the data even if a
 majority of the nodes are no longer available."""
 
+setup_requires = []
+
+# darcsver is needed only if you want "./setup.py darcsver" to write a new
+# version stamp in src/allmydata/_version.py, with a version number derived from
+# darcs history.
+# http://pypi.python.org/pypi/darcsver
+setup_requires.append('darcsver >= 1.0.0')
+
+# setuptools_darcs is required only if you want to use "./setup.py sdist",
+# "./setup.py bdist", and the other "dist" commands -- it is necessary for them
+# to produce complete distributions, which need to include all files that are
+# under darcs revision control.
+# http://pypi.python.org/pypi/setuptools_darcs
+setup_requires.append('setuptools_darcs >= 1.0.5')
+
 setup(name='allmydata-tahoe',
       version=verstr,
       description='secure, distributed storage grid',
@@ -122,7 +129,7 @@ setup(name='allmydata-tahoe',
       test_suite="allmydata.test",
       install_requires=install_requires,
       include_package_data=True,
-      setup_requires=['setuptools_darcs >= 1.0.5', 'pyutil >= 1.3.8'], # pyutil is for darcsver
+      setup_requires=setup_requires,
       dependency_links=dependency_links,
       entry_points = { 'console_scripts': [ 'tahoe = allmydata.scripts.runner:run' ] },
       zip_safe=False, # We prefer unzipped for easier access.
-- 
2.45.2