Remove darcs from setup.py, remove darcsver egg. Closes #1908.

Also remove lingering traces of darcs from MANIFEST.in,
.darcs-boringfile, setup.cfg, and unit tests.
This commit is contained in:
Brian Warner 2013-03-19 15:26:21 -07:00
parent 9e449db50b
commit 19b2ef9764
18 changed files with 24 additions and 783 deletions

View File

@ -1,83 +0,0 @@
# Boring file regexps:
\.hi$
\.o$
\.o\.cmd$
# *.ko files aren't boring by default because they might
# be Korean translations rather than kernel modules.
# \.ko$
\.ko\.cmd$
\.mod\.c$
(^|/)\.tmp_versions($|/)
(^|/)CVS($|/)
(^|/)RCS($|/)
~$
#(^|/)\.[^/]
(^|/)_darcs($|/)
\.bak$
\.BAK$
\.orig$
(^|/)vssver\.scc$
\.swp$
(^|/)MT($|/)
(^|/)\{arch\}($|/)
(^|/).arch-ids($|/)
(^|/),
\.class$
\.prof$
(^|/)\.DS_Store$
(^|/)BitKeeper($|/)
(^|/)ChangeSet($|/)
(^|/)\.svn($|/)
(^|/)\.git($|/)
\.py[co]$
\#
\.cvsignore$
(^|/)Thumbs\.db$
(^|/)autom4te\.cache($|/)
^_trial_temp.*($|/)
^\.buildbot($|/)
^MANIFEST$
^dist($|/)
^debian($|/)
^build($|/)
^build-stamp$
^python-build-stamp-2.[4567]$
^\.coverage$
^coverage-html($|/)
^twisted/plugins/dropin\.cache$
^\.coverage\.el$
^_test_memory($|/)
# _version.py is generated at build time, and never checked in
^src/allmydata/_version\.py$
# _appname.py is generated at build time, and never checked in
^src/allmydata/_appname\.py$
# bin/tahoe scripts (not including tahoe-script.template) are generated files
^bin/tahoe$
^bin/tahoe\.pyscript$
^bin/tahoe-script\.py$
# this file is maintained by the buildbot
^\.buildbot-sourcedata$
# automatically-built dependencies (using the 'build-deps' target) go here
^support
# creating a tahoe egg puts files here
allmydata_tahoe.egg-info$
^Twisted-.*\.egg/
# zipped .eggs are boring, contents of .egg directories are not
^.*\.egg$
^\.checked-deps$
^\.built$
^misc/dependencies/build($|/)
^misc/dependencies/temp($|/)
^tahoe-deps($|/)
^tahoe-deps\.tar\.gz$

View File

@ -1,12 +1,11 @@
include COPYING.GPL COPYING.TGPPL.rst CREDITS Makefile NEWS.rst Tahoe.home
include relnotes.txt .darcs-boringfile
include relnotes.txt
include bin/tahoe-script.template
recursive-include src *.xhtml *.js *.png *.css
recursive-include twisted *.py
graft docs
graft misc
graft static
graft darcsver-1.7.2.egg
graft setuptools-0.6c16dev4.egg
global-exclude *~ *.pyc

View File

@ -1,121 +0,0 @@
Metadata-Version: 1.0
Name: darcsver
Version: 1.7.2
Summary: generate a version number from darcs history
Home-page: http://tahoe-lafs.org/trac/darcsver
Author: Zooko O'Whielacronx
Author-email: zooko@zooko.com
License: BSD
Description: darcsver - generate version numbers from darcs revision control history
=======================================================================
What Does It Do
---------------
Create files containing version numbers, based upon the latest darcs
release tag.
If your source tree is coming from darcs (i.e. it is in a darcs
repository), this tool will determine the most recent release tag,
count the patches that have been applied since then, and compute a
version number to be written into _version.py (and optionally other
version files). This version number will be available by doing:
from your_package_name import __version__
Source trees that do not come from darcs (e.g. release tarballs, nightly
tarballs) and are not within a darcs repository should instead, come with a
_version.py that was generated before the tarball was produced. In this case,
this tool will quietly exit without modifying the existing _version.py .
'release tags' are tags in the source repository that match the following
regexp:
^your_package_name-(\d+)(\.(\d+)(\.(\d+))?)?((a|b|c|rc)(\d+))?
Installation
------------
With easy_install:
easy_install darcsver
Alternative manual installation:
tar -zxvf darcsver-X.Y.Z.tar.gz
cd darcsver-X.Y.Z
python setup.py install
Where X.Y.Z is a version number.
Alternative to make a specific package use darcsver without installing
darcsver into the system:
Put "setup_requires=['darcsver']" in the call to setup() in the
package's setup.py file.
Usage
-----
There are two ways to use this: the command-line tool and the
setuptools plugin.
To use the command-line tool, execute it as:
darcsver $PACKAGE_NAME $PATH_TO_VERSION_PY
To use the setuptools plugin (which enables you to write "./setup.py
darcsver" and which cleverly figures out where the _version.py file
ought to go), you must first package your python module with
`setup.py` and use setuptools.
The former is well documented in the distutils manual:
http://docs.python.org/dist/dist.html
To use setuptools instead of distutils, just edit `setup.py` and
change
from distutils.core import setup
to
from setuptools import setup
References
----------
How to distribute Python modules with Distutils:
http://docs.python.org/dist/dist.html
Setuptools complete manual:
http://peak.telecommunity.com/DevCenter/setuptools
Thanks to Yannick Gingras for providing the prototype for this
README.txt.
Keywords: distutils setuptools plugin setup darcs
Platform: UNKNOWN
Classifier: Framework :: Setuptools Plugin
Classifier: Development Status :: 5 - Production/Stable
Classifier: License :: OSI Approved :: BSD License
Classifier: License :: DFSG approved
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Natural Language :: English
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 2
Classifier: Programming Language :: Python :: 2.4
Classifier: Programming Language :: Python :: 2.5
Classifier: Programming Language :: Python :: 2.6
Classifier: Programming Language :: Python :: 2.7
Classifier: Topic :: Utilities
Classifier: Topic :: Software Development :: Libraries

View File

@ -1,16 +0,0 @@
README.txt
setup.py
darcsver/__init__.py
darcsver/_version.py
darcsver/darcsvermodule.py
darcsver/setuptools_command.py
darcsver.egg-info/PKG-INFO
darcsver.egg-info/SOURCES.txt
darcsver.egg-info/dependency_links.txt
darcsver.egg-info/entry_points.txt
darcsver.egg-info/not-zip-safe
darcsver.egg-info/top_level.txt
darcsver/test/__init__.py
darcsver/test/test_darcsver.py
scripts/__init__.py
scripts/darcsverscript.py

View File

@ -1,10 +0,0 @@
[distutils.setup_keywords]
versionbodies = darcsver.setuptools_command:validate_versionbodies
versionfiles = darcsver.setuptools_command:validate_versionfiles
[console_scripts]
darcsver = scripts.darcsverscript:main
[distutils.commands]
darcsver = darcsver.setuptools_command:DarcsVer

View File

@ -1 +0,0 @@

View File

@ -1,2 +0,0 @@
darcsver
scripts

View File

@ -1,8 +0,0 @@
__version__ = "unknown"
try:
from _version import __version__
except ImportError:
# We're running in a tree that hasn't run darcsver, and didn't come with a
# _version.py, so we don't know what our version is. This should not happen
# very often.
pass

View File

@ -1,17 +0,0 @@
# This is the version of this tree, as created by setup.py darcsver from the darcs patch
# information: the main version number is taken from the most recent release
# tag. If some patches have been added since the last release, this will have a
# -NN "build number" suffix, or else a -rNN "revision number" suffix. Please see
# pyutil.version_class for a description of what the different fields mean.
__pkgname__ = "darcsver"
verstr = "1.7.2"
try:
from pyutil.version_class import Version as pyutil_Version
__version__ = pyutil_Version(verstr)
except (ImportError, ValueError):
# Maybe there is no pyutil installed, or this may be an older version of
# pyutil.version_class which does not support SVN-alike revision numbers.
from distutils.version import LooseVersion as distutils_Version
__version__ = distutils_Version(verstr)

View File

@ -1,200 +0,0 @@
import os, string, sys, re
import xml.dom.minidom
import subprocess
PIPE=subprocess.PIPE
from distutils import log
def all(iterable):
for thing in iterable:
if not thing:
return False
return True
OUR_VERSION_BASE_RE_STR="(\d+)(\.(\d+)(\.(\d+))?)?((a|b|c)(\d+))?(\.dev(\d+))?"
try:
# If we can import pyutil.version_class then use its regex.
from pyutil import version_class
VERSION_BASE_RE_STR = version_class.VERSION_BASE_RE_STR
except (ImportError, AttributeError):
# Else (perhaps a bootstrapping problem),then we'll use this
# regex, which was copied from the pyutil source code on
# 2010-09-02.
VERSION_BASE_RE_STR=OUR_VERSION_BASE_RE_STR
def get_text(nodelist):
rc = ""
for node in nodelist:
if node.nodeType == node.TEXT_NODE:
rc = rc + node.data
return rc
VERSION_BODY = '''
# This is the version of this tree, as created by %(versiontool)s from the darcs patch
# information: the main version number is taken from the most recent release
# tag. If some patches have been added since the last release, this will have a
# -NN "build number" suffix, or else a -rNN "revision number" suffix. Please see
# pyutil.version_class for a description of what the different fields mean.
__pkgname__ = "%(pkgname)s"
verstr = "%(pkgversion)s"
try:
from pyutil.version_class import Version as pyutil_Version
__version__ = pyutil_Version(verstr)
except (ImportError, ValueError):
# Maybe there is no pyutil installed.
from distutils.version import LooseVersion as distutils_Version
__version__ = distutils_Version(verstr)
'''
def write_version_py(verstr, outfname, EXE_NAME, version_body, pkgname):
f = open(outfname, "wb+")
f.write(version_body % {
'versiontool': EXE_NAME,
'pkgversion': verstr,
'pkgname': pkgname,
})
f.close()
def read_version_py(infname):
try:
verstrline = open(infname, "rt").read()
except EnvironmentError:
return None
else:
VSRE = r"^verstr = ['\"]([^'\"]*)['\"]"
mo = re.search(VSRE, verstrline, re.M)
if mo:
return mo.group(1)
def update(pkgname, verfilename, revision_number=False, loud=False, abort_if_snapshot=False, EXE_NAME="darcsver", version_body=VERSION_BODY):
"""
@param revision_number If true, count the total number of patches in all
history. If false, count the total number of patches since the most recent
release tag.
Returns a tuple of (exit code, new version string).
"""
if isinstance(verfilename, basestring):
verfilenames = [verfilename]
else:
verfilenames = verfilename
assert all([isinstance(vfn, basestring) for vfn in verfilenames]), [vfn for vfn in verfilenames if not isinstance(vfn, basestring)]
if isinstance(version_body, basestring):
verbodies = [version_body]
else:
verbodies = version_body
rc = -1
# First we try "darcs query repo" because if that fails then we
# won't try "darcs changes" at all, because "darcs changes" emits
# an ugly error message when run in not-a-repo.
try:
p = subprocess.Popen(["darcs", 'query', 'repo'], stdout=PIPE, stderr=PIPE, universal_newlines=True)
except OSError, ose:
if ose.errno == 2 and '~' in os.environ['PATH']:
expanded_path = os.environ['PATH'].replace('~', os.path.expanduser('~'))
msg = ("WARNING: 'darcs' was not found. However '~' was found in your PATH. \n"
"Please note that bugs in python cause it to fail to traverse '~' in \n"
"the user's PATH. Please fix your path, e.g. \nPATH=%s" )
log.warn(msg % (expanded_path,))
pass
else:
(output, errput) = p.communicate()
rc = p.returncode
if rc == 0:
cmd = ["changes", "--xml-output"]
if not revision_number:
cmd.append("--from-tag=^%s" % (pkgname,))
try:
p = subprocess.Popen(["darcs"] + cmd, stdout=PIPE, stderr=PIPE, universal_newlines=True)
except OSError:
pass
else:
(output, errput) = p.communicate()
rc = p.returncode
if rc != 0 and errput:
log.info("%s: darcs wrote to stderr: '%s'" % (EXE_NAME, errput,))
errput = None
else:
if all([os.path.exists(vfn) for vfn in verfilenames]):
log.info("%s: using extant version file %s" % (EXE_NAME, verfilenames))
return (0, read_version_py(verfilenames[0]))
else:
log.warn("%s: didn't find version tags with darcs, and %s don't exist." % (EXE_NAME, verfilenames))
return (rc, None)
# Filter out bad chars that can cause the XML parser to give up in despair.
# (Thanks to lelit of the tailor project and ndurner and warner for this hack.)
allbadchars = "".join([chr(i) for i in range(0x0a) + [0x0b, 0x0c] + range(0x0e, 0x20) + range(0x7f,0x100)])
tt = string.maketrans(allbadchars, "-"*len(allbadchars))
output = output.translate(tt)
regexstr = "^TAG %s-(%s)$" % (pkgname, VERSION_BASE_RE_STR)
last_tag = None
# strip off trailing warning messages that darcs 2.3.1 writes to stdout
endi = output.find("</changelog>")+len("</changelog>")
if endi != -1:
output = output[:endi]
try:
doc = xml.dom.minidom.parseString(output)
except xml.parsers.expat.ExpatError:
# Okay maybe this is an error message instead of an XML output.
pass
else:
changelog = doc.getElementsByTagName("changelog")[0]
patches = changelog.getElementsByTagName("patch")
version_re = re.compile(regexstr)
count_since_last_patch = 0
if abort_if_snapshot:
for patch in patches:
name = get_text(patch.getElementsByTagName("name")[0].childNodes)
m = version_re.match(name)
if m:
last_tag = m.group(1)
last_tag = last_tag.encode("utf-8")
break
else:
sys.exit(0) # because abort_if_snapshot
else:
for patch in patches:
name = get_text(patch.getElementsByTagName("name")[0].childNodes)
m = version_re.match(name)
if m:
last_tag = m.group(1)
last_tag = last_tag.encode("utf-8")
break
else:
count_since_last_patch += 1
if not last_tag:
if errput:
log.info("%s: darcs wrote to stderr: '%s'" % (EXE_NAME, errput,))
errput = None
assert all([isinstance(vfn, basestring) for vfn in verfilenames]), [vfn for vfn in verfilenames if not isinstance(vfn, basestring)]
if all([os.path.exists(vfn) for vfn in verfilenames]):
log.warn("%s: I'm unable to find a tag in the darcs history matching \"%s\", so I'm leaving %s alone." % (EXE_NAME, regexstr, verfilenames,))
return (0, read_version_py(verfilenames[0]))
else:
log.warn("%s: I'm unable to find a tag in the darcs history matching \"%s\", and %s don't exist." % (EXE_NAME, regexstr, verfilenames,))
return (-1, None)
if revision_number:
if count_since_last_patch:
# this is an interim version
verstr = "%s-r%d" % (last_tag, len(patches))
else:
# this is a release
verstr = last_tag
else:
if count_since_last_patch:
# this is an interim version
verstr = "%s-%d" % (last_tag, count_since_last_patch)
else:
# this is a release
verstr = last_tag
for verfn, verbod in zip(verfilenames, verbodies):
write_version_py(verstr, verfn, EXE_NAME, verbod, pkgname)
log.info("%s: wrote '%s' into %s" % (EXE_NAME, verstr, verfn,))
return (0, verstr)

View File

@ -1,126 +0,0 @@
import os
import setuptools
from darcsver import darcsvermodule
from distutils.errors import DistutilsSetupError
def validate_string_or_iter_of_strings(dist, attr, value):
# value is required to be a string or else a list of strings
if isinstance(value, basestring):
return
try:
for thing in value:
if not isinstance(thing, basestring):
raise DistutilsSetupError("%r is required to be a string or an iterable of strings (got %r)" % (attr, value))
except TypeError:
raise DistutilsSetupError("%r is required to be a string or an iterable of strings (got %r)" % (attr, value))
def validate_versionfiles(dist, attr, value):
return validate_string_or_iter_of_strings(dist, attr, value)
def validate_versionbodies(dist, attr, value):
return validate_string_or_iter_of_strings(dist, attr, value)
def all(iterator):
for thing in iterator:
if not thing:
return False
return True
PYTHON_VERSION_BODY='''
# This is the version of this tree, as created by %(versiontool)s from the darcs patch
# information: the main version number is taken from the most recent release
# tag. If some patches have been added since the last release, this will have a
# -NN "build number" suffix, or else a -rNN "revision number" suffix. Please see
# pyutil.version_class for a description of what the different fields mean.
__pkgname__ = "%(pkgname)s"
verstr = "%(pkgversion)s"
try:
from pyutil.version_class import Version as pyutil_Version
__version__ = pyutil_Version(verstr)
except (ImportError, ValueError):
# Maybe there is no pyutil installed, or this may be an older version of
# pyutil.version_class which does not support SVN-alike revision numbers.
from distutils.version import LooseVersion as distutils_Version
__version__ = distutils_Version(verstr)
'''
class DarcsVer(setuptools.Command):
description = "generate a version number from darcs history"
user_options = [
('project-name', None, "name of the project as it appears in the project's release tags (default's the to the distribution name)"),
('filename', None, "path to file into which the version number should be written (defaults to the package directory's _version.py)"),
('count-all-patches', None, "If true, count the total number of patches in all history. If false, count the total number of patches since the most recent release tag."),
('abort-if-snapshot', None, "If true, the if the current version is a snapshot (not a release tag), then immediately exit the process with exit code 0."),
]
def initialize_options(self):
self.project_name = None
self.filename = None
self.count_all_patches = None
self.abort_if_snapshot = None
def finalize_options(self):
if self.project_name is None:
self.project_name = self.distribution.get_name()
# If the user passed --filename on the cmdline, override
# the setup.py's versionfiles argument.
if self.filename is not None:
if not isinstance(self.filename, basestring):
raise TypeError("filename is required to be a string, not %s, filename: %s" % (type(self.filename), self.filename))
self.distribution.versionfiles = [self.filename]
if self.abort_if_snapshot is None:
self.abort_if_snapshot=False
def run(self):
if self.distribution.versionfiles is None:
toppackage = ''
# If there is a package with the same name as the project name and
# there is a directory by that name then use that.
packagedir = None
if self.distribution.packages and self.project_name in self.distribution.packages:
toppackage = self.project_name
srcdir = ''
if self.distribution.package_dir:
srcdir = self.distribution.package_dir.get(toppackage)
if not srcdir is None:
srcdir = self.distribution.package_dir.get('', '')
packagedir = os.path.join(srcdir, toppackage)
if packagedir is None or not os.path.isdir(packagedir):
# Else, if there is a singly-rooted tree of packages, use the
# root of that.
if self.distribution.packages:
for package in self.distribution.packages:
if not toppackage:
toppackage = package
else:
if toppackage.startswith(package+"."):
toppackage = package
else:
if not package.startswith(toppackage+"."):
# Not singly-rooted
toppackage = ''
break
srcdir = ''
if self.distribution.package_dir:
srcdir = self.distribution.package_dir.get(toppackage)
if srcdir is None:
srcdir = self.distribution.package_dir.get('', '')
packagedir = os.path.join(srcdir, toppackage)
self.distribution.versionfiles = [os.path.join(packagedir, '_version.py')]
if self.distribution.versionbodies is None:
self.distribution.versionbodies = [PYTHON_VERSION_BODY]
assert all([isinstance(vfn, basestring) for vfn in self.distribution.versionfiles]), self.distribution.versionfiles
(rc, verstr) = darcsvermodule.update(self.project_name, self.distribution.versionfiles, self.count_all_patches, abort_if_snapshot=self.abort_if_snapshot, EXE_NAME="setup.py darcsver", version_body=self.distribution.versionbodies)
if rc == 0:
self.distribution.metadata.version = verstr

View File

@ -1,46 +0,0 @@
#! /usr/bin/env python
from optparse import OptionParser
import os, sys
from darcsver import darcsvermodule, __version__
try:
EXE_NAME=os.path.basename(sys.argv[0])
except:
EXE_NAME="darcsver"
def main():
parser = OptionParser(usage="Usage: %prog [options] [pkgname [verfilename]]",
version="%prog " + str(__version__),
prog=EXE_NAME)
parser.add_option("-q", "--quiet", default=False, action="store_true",
help="Be quiet, do the job without any output.")
parser.add_option("--count-all-patches", "--revision-number", default=False,
action="store_true", dest="count_all_patches",
help="By default %s counts the number of patches since the "
"most recent release tag. With this option, it counts "
"all the patches in the repository." % EXE_NAME)
options, args = parser.parse_args()
if args:
pkgname = args.pop(0)
else:
pkgname = os.path.basename(os.getcwd())
if not options.quiet:
print "%s: You didn't pass a pkg-name on the command-line, so I'm going to take the name of the current working directory: \"%s\"" % (EXE_NAME, pkgname,)
if args:
verfilename = args.pop(0)
else:
verfilename = os.path.join(pkgname, "_version.py")
if not options.quiet:
print "%s: You didn't pass a verfilename on the command-line, so I'm going to build one from the name of the package: \"%s\"" % (EXE_NAME, verfilename,)
(rc, newverstr) = darcsvermodule.update(pkgname=pkgname, verfilename=verfilename, revision_number=options.count_all_patches, quiet=options.quiet, EXE_NAME=EXE_NAME)
return rc
if __name__ == "__main__":
rc = main()
sys.exit(rc)

View File

@ -1,95 +0,0 @@
darcsver - generate version numbers from darcs revision control history
=======================================================================
What Does It Do
---------------
Create files containing version numbers, based upon the latest darcs
release tag.
If your source tree is coming from darcs (i.e. it is in a darcs
repository), this tool will determine the most recent release tag,
count the patches that have been applied since then, and compute a
version number to be written into _version.py (and optionally other
version files). This version number will be available by doing:
from your_package_name import __version__
Source trees that do not come from darcs (e.g. release tarballs, nightly
tarballs) and are not within a darcs repository should instead, come with a
_version.py that was generated before the tarball was produced. In this case,
this tool will quietly exit without modifying the existing _version.py .
'release tags' are tags in the source repository that match the following
regexp:
^your_package_name-(\d+)(\.(\d+)(\.(\d+))?)?((a|b|c|rc)(\d+))?
Installation
------------
With easy_install:
easy_install darcsver
Alternative manual installation:
tar -zxvf darcsver-X.Y.Z.tar.gz
cd darcsver-X.Y.Z
python setup.py install
Where X.Y.Z is a version number.
Alternative to make a specific package use darcsver without installing
darcsver into the system:
Put "setup_requires=['darcsver']" in the call to setup() in the
package's setup.py file.
Usage
-----
There are two ways to use this: the command-line tool and the
setuptools plugin.
To use the command-line tool, execute it as:
darcsver $PACKAGE_NAME $PATH_TO_VERSION_PY
To use the setuptools plugin (which enables you to write "./setup.py
darcsver" and which cleverly figures out where the _version.py file
ought to go), you must first package your python module with
`setup.py` and use setuptools.
The former is well documented in the distutils manual:
http://docs.python.org/dist/dist.html
To use setuptools instead of distutils, just edit `setup.py` and
change
from distutils.core import setup
to
from setuptools import setup
References
----------
How to distribute Python modules with Distutils:
http://docs.python.org/dist/dist.html
Setuptools complete manual:
http://peak.telecommunity.com/DevCenter/setuptools
Thanks to Yannick Gingras for providing the prototype for this
README.txt.

View File

@ -14,12 +14,13 @@ zip_ok=False
# PyPI.
# https://tahoe-lafs.org/source/tahoe-lafs/deps/tahoe-deps.tar.gz contains a
# bundle of these dependencies (as Python source distributions or "sdists"). So
# it you want to avoid the build-time download (say, if you're on an airplane,
# or a desert island), just grab a copy and unpack it in your tahoe darcs tree.
# bundle of these dependencies (as Python source distributions or "sdists").
# So it you want to avoid the build-time download (say, if you're on an
# airplane, or a desert island), just grab a copy and unpack it in your tahoe
# source tree.
# Alternatively, if you're building from a release/nightly tarball instead of
# a darcs tree, the 'sumo' tarball variant will include all of these
# a git tree, the 'sumo' tarball variant will include all of these
# dependencies in the tahoe-deps/ directory.
find_links=misc/dependencies tahoe-deps ../tahoe-deps

View File

@ -72,8 +72,6 @@ __requires__ = install_requires[:]
egg = os.path.realpath(glob.glob('setuptools-*.egg')[0])
sys.path.insert(0, egg)
egg = os.path.realpath(glob.glob('darcsver-*.egg')[0])
sys.path.insert(0, egg)
import setuptools; setuptools.bootstrap_install_from = egg
from setuptools import setup
@ -120,20 +118,6 @@ trove_classifiers=[
setup_requires = []
# The darcsver command from the darcsver plugin is needed to initialize the
# distribution's .version attribute correctly. (It does this either by
# examining darcs history, or if that fails by reading the
# src/allmydata/_version.py file). darcsver will also write a new version
# stamp in src/allmydata/_version.py, with a version number derived from
# darcs history. Note that the setup.cfg file has an "[aliases]" section
# which enumerates commands that you might run and specifies that it will run
# darcsver before each one. If you add different commands (or if I forgot
# some that are already in use), you may need to add it to setup.cfg and
# configure it to run darcsver before your command, if you want the version
# number to be correct when that command runs.
# http://pypi.python.org/pypi/darcsver
setup_requires.append('darcsver >= 1.7.2')
# Nevow imports itself when building, which causes Twisted and zope.interface
# to be imported. We need to make sure that the versions of Twisted and
# zope.interface used at build time satisfy Nevow's requirements. If not
@ -256,15 +240,6 @@ class MakeExecutable(Command):
raise
DARCS_VERSION_BODY = '''
# This _version.py is generated from darcs metadata by the tahoe setup.py
# and the "darcsver" package.
__pkgname__ = "%(pkgname)s"
verstr = "%(pkgversion)s"
__version__ = verstr
'''
GIT_VERSION_BODY = '''
# This _version.py is generated from git metadata by the tahoe setup.py.
@ -343,6 +318,11 @@ def versions_from_git(tag_prefix, verbose=False):
normalized_version += ".dev0"
return {"version": version, "normalized": normalized_version, "full": full}
# setup.cfg has an [aliases] section which runs "update_version" before many
# commands (like "build" and "sdist") that need to know our package version
# ahead of time. If you add different commands (or if we forgot some), you
# may need to add it to setup.cfg and configure it to run update_version
# before your command.
class UpdateVersion(Command):
description = "update _version.py from revision-control metadata"
@ -353,30 +333,18 @@ class UpdateVersion(Command):
def finalize_options(self):
pass
def run(self):
target = self.distribution.versionfiles[0]
if os.path.isdir(os.path.join(basedir, "_darcs")):
verstr = self.try_from_darcs(target)
elif os.path.isdir(os.path.join(basedir, ".git")):
verstr = self.try_from_git(target)
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
def try_from_darcs(self, target):
from darcsver.darcsvermodule import update
(rc, verstr) = update(pkgname=self.distribution.get_name(),
verfilename=self.distribution.versionfiles,
revision_number=True,
version_body=DARCS_VERSION_BODY)
if rc == 0:
return verstr
def try_from_git(self, target):
def try_from_git(self):
versions = versions_from_git("allmydata-tahoe-", verbose=True)
if versions:
for fn in self.distribution.versionfiles:
fn = 'src/allmydata/_version.py'
f = open(fn, "wb")
f.write(GIT_VERSION_BODY %
{ "pkgname": self.distribution.get_name(),
@ -479,6 +447,5 @@ setup(name=APPNAME,
setup_requires=setup_requires,
entry_points = { 'console_scripts': [ 'tahoe = allmydata.scripts.runner:run' ] },
zip_safe=False, # We prefer unzipped for easier access.
versionfiles=['src/allmydata/_version.py',],
**setup_args
)

View File

@ -154,7 +154,7 @@ class BinTahoe(common_util.SignalMixin, unittest.TestCase, RunBinTahoeMixin):
self.failIfEqual(required_verstr, "unknown",
"We don't know our version, because this distribution didn't come "
"with a _version.py and 'setup.py darcsver' hasn't been run.")
"with a _version.py and 'setup.py update_version' hasn't been run.")
srcdir = os.path.dirname(os.path.dirname(os.path.normcase(os.path.realpath(srcfile))))
info = repr((res, allmydata.__appname__, required_verstr, srcdir))