From: Zooko O'Whielacronx Date: Fri, 21 Dec 2007 21:42:38 +0000 (-0700) Subject: setup: finish switching from Tahoe's versions of autoversioning tools to pyutil's... X-Git-Url: https://git.rkrishnan.org/readonly?a=commitdiff_plain;h=1ac11301a777504c85f2f774b54b6e211bc12ec6;p=tahoe-lafs%2Ftahoe-lafs.git setup: finish switching from Tahoe's versions of autoversioning tools to pyutil's versions --- diff --git a/setup.py b/setup.py index 5db72d84..dddd5e16 100644 --- a/setup.py +++ b/setup.py @@ -20,7 +20,7 @@ # Inc., please contact partnerships@allmydata.com and visit # http://allmydata.com/. -import sys, re, os.path +import sys, re, os try: from ez_setup import use_setuptools except ImportError: @@ -78,25 +78,24 @@ trove_classifiers=[ # running from a darcs checkout, this will leave any pre-existing _version.py # alone. try: - os.system(" ".join([sys.executable, - "misc/make-version.py", - "allmydata-tahoe", - '"src/allmydata/_version.py"', # cygwin vs slashes - ])) + (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" -if os.path.exists(VERSIONFILE): - VSRE = re.compile("^verstr = ['\"]([^'\"]*)['\"]", re.M) +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 src/allmydata/_version.py" - raise RuntimeError("if _version.py exists, it must be well-formed") - + print "unable to find version in %s" % (VERSIONFILE,) + raise RuntimeError("if %s.py exists, it is required to be well-formed" % (VERSIONFILE,)) LONG_DESCRIPTION=\ """Welcome to the AllMyData "tahoe" project. This project implements a secure, @@ -125,4 +124,5 @@ setup(name='allmydata-tahoe', dependency_links=dependency_links, entry_points = { 'console_scripts': [ 'tahoe = allmydata.scripts.runner:run' ] }, zip_safe=False, # We prefer unzipped for easier access. + extras_require={'autoversioning':'pyutil >= 1.3.8'}, ) diff --git a/src/allmydata/__init__.py b/src/allmydata/__init__.py index 793827ad..a347c523 100644 --- a/src/allmydata/__init__.py +++ b/src/allmydata/__init__.py @@ -11,8 +11,9 @@ __version__ = "unknown" try: from _version import __version__ except ImportError: - # we're running in a tree that hasn't run misc/make-version.py, so we - # don't know what our version is. This should not happen very often. + # we're running in a tree that hasn't run darcsver from the pyutil library, + # nor did it come with a pre-generated _version.py, so we don't know what + # our version is. This should not happen very often. pass hush_pyflakes = __version__ diff --git a/src/allmydata/node.py b/src/allmydata/node.py index 712662ee..1a0a8113 100644 --- a/src/allmydata/node.py +++ b/src/allmydata/node.py @@ -15,10 +15,9 @@ from allmydata.util.assertutil import precondition import allmydata, pycryptopp, zfec from foolscap.logging.publish import LogPublisher -# Add our application versions to the data that Foolscap's -# LogPublisher reports. Our __version__ attributes are actually -# instances of allmydata.util.version_class.Version, so convert them -# into strings first. +# Add our application versions to the data that Foolscap's LogPublisher +# reports. Our __version__ attributes are actually instances of a "Version" +# class, so convert them into strings first. LogPublisher.versions['allmydata'] = str(allmydata.__version__) LogPublisher.versions['zfec'] = str(zfec.__version__) LogPublisher.versions['pycryptopp'] = str(pycryptopp.__version__) diff --git a/src/allmydata/test/test_client.py b/src/allmydata/test/test_client.py index 36b2eef7..2a04c0ab 100644 --- a/src/allmydata/test/test_client.py +++ b/src/allmydata/test/test_client.py @@ -6,7 +6,7 @@ from twisted.internet import reactor, defer import allmydata from allmydata import client, introducer -from allmydata.util import version_class, idlib +from allmydata.util import idlib from foolscap.eventual import flushEventualQueue class FakeIntroducerClient(introducer.IntroducerClient): @@ -120,7 +120,7 @@ class Basic(unittest.TestCase): open(os.path.join(basedir, "vdrive.furl"), "w").write("") c = client.Client(basedir) mine, oldest = c.remote_get_versions() - self.failUnlessEqual(version_class.Version(mine), allmydata.__version__) + self.failUnlessEqual(mine, allmydata.__version__) def flush_but_dont_ignore(res): d = flushEventualQueue() diff --git a/src/allmydata/util/version_class.py b/src/allmydata/util/version_class.py deleted file mode 100644 index b457fa1a..00000000 --- a/src/allmydata/util/version_class.py +++ /dev/null @@ -1,134 +0,0 @@ -# Copyright (c) 2004-2007 Bryce "Zooko" Wilcox-O'Hearn -# mailto:zooko@zooko.com -# http://zooko.com/repos/pyutil -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this work to deal in this work without restriction (including the rights -# to use, modify, distribute, sublicense, and/or sell copies). - -""" -extended version number class -""" - -# from setuptools, but intended to be included in future version of Python Standard Library (PEP 365) -try: - import pkg_resources -except ImportError: - import distutils.version - def cmp_version(v1, v2): - return cmp(distutils.version.LooseVersion(str(v1)), distutils.version.LooseVersion(str(v2))) -else: - def cmp_version(v1, v2): - return cmp(pkg_resources.parse_version(str(v1)), pkg_resources.parse_version(str(v2))) - -# Python Standard Library -import re - -# End users see version strings like this: - -# "1.0.0" -# ^ ^ ^ -# | | | -# | | '- micro version number -# | '- minor version number -# '- major version number - -# The first number is "major version number". The second number is the "minor -# version number" -- it gets bumped whenever we make a new release that adds or -# changes functionality. The third version is the "micro version number" -- it -# gets bumped whenever we make a new release that doesn't add or change -# functionality, but just fixes bugs (including performance issues). - -# Early-adopter end users see version strings like this: - -# "1.0.0a1" -# ^ ^ ^^^ -# | | ||| -# | | ||'- release number -# | | |'- a=alpha, b=beta, c=release candidate, or none -# | | '- micro version number -# | '- minor version number -# '- major version number - -# The optional "a" or "b" stands for "alpha release" or "beta release" -# respectively. The number after "a" or "b" gets bumped every time we -# make a new alpha or beta release. This has the same form and the same -# meaning as version numbers of releases of Python. - -# Developers see "full version strings", like this: - -# "1.0.0a1-55" -# ^ ^ ^^^ ^ -# | | ||| | -# | | ||| '- nano version number -# | | ||'- release number -# | | |'- a=alpha, b=beta, c=release candidate or none -# | | '- micro version number -# | '- minor version number -# '- major version number - -# The presence of the nano version number means that this is a development -# version. There are no guarantees about compatibility, etc. This version is -# considered to be more recent than the version without this field -# (e.g. "1.0.0a1"). - -# The nano version number is meaningful only to developers. It gets generated -# automatically from darcs revision control history by "make-version.py". It -# is the count of patches that have been applied since the last version number -# tag was applied. - -VERSION_BASE_RE_STR="(\d+)\.(\d+)(\.(\d+))?((a|b|c)(\d+))?" -VERSION_RE_STR=VERSION_BASE_RE_STR + "(-(\d+))?" -VERSION_RE=re.compile("^" + VERSION_RE_STR + "$") - -class Version(object): - def __init__(self, vstring=None): - self.major = None - self.minor = None - self.micro = None - self.prereleasetag = None - self.prerelease = None - self.nano = None - self.leftovers = '' - if vstring: - try: - self.parse(vstring) - except ValueError, le: - le.args = tuple(le.args + ('vstring:', vstring,)) - raise - - def parse(self, vstring): - mo = VERSION_RE.search(vstring) - if not mo: - raise ValueError, "Not a valid version string for allmydata.util.version_class.Version(): %r" % (vstring,) - - self.major = int(mo.group(1)) - self.minor = int(mo.group(2)) - self.micro = int(mo.group(4)) - reltag = mo.group(5) - if reltag: - reltagnum = int(mo.group(6)) - self.prereleasetag = reltag - self.prerelease = reltagnum - - if mo.group(8): - self.nano = int(mo.group(9)) - - self.fullstr = "%d.%d.%d%s%s" % (self.major, self.minor, self.micro, self.prereleasetag and "%s%d" % (self.prereleasetag, self.prerelease,) or "", self.nano and "-%d" % (self.nano,) or "",) - - def user_str(self): - return self.strictversion.__str__() - - def full_str(self): - if hasattr(self, 'fullstr'): - return self.fullstr - else: - return 'None' - - def __str__(self): - return self.full_str() - - def __repr__(self): - return self.__str__() - - def __cmp__ (self, other): - return cmp_version(self, other)