mirror of
https://github.com/tahoe-lafs/tahoe-lafs.git
synced 2025-06-18 15:28:12 +00:00
setup: finish switching from Tahoe's versions of autoversioning tools to pyutil's versions
This commit is contained in:
20
setup.py
20
setup.py
@ -20,7 +20,7 @@
|
|||||||
# Inc., please contact partnerships@allmydata.com and visit
|
# Inc., please contact partnerships@allmydata.com and visit
|
||||||
# http://allmydata.com/.
|
# http://allmydata.com/.
|
||||||
|
|
||||||
import sys, re, os.path
|
import sys, re, os
|
||||||
try:
|
try:
|
||||||
from ez_setup import use_setuptools
|
from ez_setup import use_setuptools
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@ -78,25 +78,24 @@ trove_classifiers=[
|
|||||||
# running from a darcs checkout, this will leave any pre-existing _version.py
|
# running from a darcs checkout, this will leave any pre-existing _version.py
|
||||||
# alone.
|
# alone.
|
||||||
try:
|
try:
|
||||||
os.system(" ".join([sys.executable,
|
(cin, cout, cerr,) = os.popen3("darcsver --quiet allmydata-tahoe src/allmydata/_version.py")
|
||||||
"misc/make-version.py",
|
print cout.read()
|
||||||
"allmydata-tahoe",
|
|
||||||
'"src/allmydata/_version.py"', # cygwin vs slashes
|
|
||||||
]))
|
|
||||||
except Exception, le:
|
except Exception, le:
|
||||||
pass
|
pass
|
||||||
VERSIONFILE = "src/allmydata/_version.py"
|
VERSIONFILE = "src/allmydata/_version.py"
|
||||||
verstr = "unknown"
|
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()
|
verstrline = open(VERSIONFILE, "rt").read()
|
||||||
|
except EnvironmentError:
|
||||||
|
pass # Okay, there is no version file.
|
||||||
|
else:
|
||||||
mo = VSRE.search(verstrline)
|
mo = VSRE.search(verstrline)
|
||||||
if mo:
|
if mo:
|
||||||
verstr = mo.group(1)
|
verstr = mo.group(1)
|
||||||
else:
|
else:
|
||||||
print "unable to find version in src/allmydata/_version.py"
|
print "unable to find version in %s" % (VERSIONFILE,)
|
||||||
raise RuntimeError("if _version.py exists, it must be well-formed")
|
raise RuntimeError("if %s.py exists, it is required to be well-formed" % (VERSIONFILE,))
|
||||||
|
|
||||||
|
|
||||||
LONG_DESCRIPTION=\
|
LONG_DESCRIPTION=\
|
||||||
"""Welcome to the AllMyData "tahoe" project. This project implements a secure,
|
"""Welcome to the AllMyData "tahoe" project. This project implements a secure,
|
||||||
@ -125,4 +124,5 @@ setup(name='allmydata-tahoe',
|
|||||||
dependency_links=dependency_links,
|
dependency_links=dependency_links,
|
||||||
entry_points = { 'console_scripts': [ 'tahoe = allmydata.scripts.runner:run' ] },
|
entry_points = { 'console_scripts': [ 'tahoe = allmydata.scripts.runner:run' ] },
|
||||||
zip_safe=False, # We prefer unzipped for easier access.
|
zip_safe=False, # We prefer unzipped for easier access.
|
||||||
|
extras_require={'autoversioning':'pyutil >= 1.3.8'},
|
||||||
)
|
)
|
||||||
|
@ -11,8 +11,9 @@ __version__ = "unknown"
|
|||||||
try:
|
try:
|
||||||
from _version import __version__
|
from _version import __version__
|
||||||
except ImportError:
|
except ImportError:
|
||||||
# we're running in a tree that hasn't run misc/make-version.py, so we
|
# we're running in a tree that hasn't run darcsver from the pyutil library,
|
||||||
# don't know what our version is. This should not happen very often.
|
# 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
|
pass
|
||||||
|
|
||||||
hush_pyflakes = __version__
|
hush_pyflakes = __version__
|
||||||
|
@ -15,10 +15,9 @@ from allmydata.util.assertutil import precondition
|
|||||||
import allmydata, pycryptopp, zfec
|
import allmydata, pycryptopp, zfec
|
||||||
|
|
||||||
from foolscap.logging.publish import LogPublisher
|
from foolscap.logging.publish import LogPublisher
|
||||||
# Add our application versions to the data that Foolscap's
|
# Add our application versions to the data that Foolscap's LogPublisher
|
||||||
# LogPublisher reports. Our __version__ attributes are actually
|
# reports. Our __version__ attributes are actually instances of a "Version"
|
||||||
# instances of allmydata.util.version_class.Version, so convert them
|
# class, so convert them into strings first.
|
||||||
# into strings first.
|
|
||||||
LogPublisher.versions['allmydata'] = str(allmydata.__version__)
|
LogPublisher.versions['allmydata'] = str(allmydata.__version__)
|
||||||
LogPublisher.versions['zfec'] = str(zfec.__version__)
|
LogPublisher.versions['zfec'] = str(zfec.__version__)
|
||||||
LogPublisher.versions['pycryptopp'] = str(pycryptopp.__version__)
|
LogPublisher.versions['pycryptopp'] = str(pycryptopp.__version__)
|
||||||
|
@ -6,7 +6,7 @@ from twisted.internet import reactor, defer
|
|||||||
|
|
||||||
import allmydata
|
import allmydata
|
||||||
from allmydata import client, introducer
|
from allmydata import client, introducer
|
||||||
from allmydata.util import version_class, idlib
|
from allmydata.util import idlib
|
||||||
from foolscap.eventual import flushEventualQueue
|
from foolscap.eventual import flushEventualQueue
|
||||||
|
|
||||||
class FakeIntroducerClient(introducer.IntroducerClient):
|
class FakeIntroducerClient(introducer.IntroducerClient):
|
||||||
@ -120,7 +120,7 @@ class Basic(unittest.TestCase):
|
|||||||
open(os.path.join(basedir, "vdrive.furl"), "w").write("")
|
open(os.path.join(basedir, "vdrive.furl"), "w").write("")
|
||||||
c = client.Client(basedir)
|
c = client.Client(basedir)
|
||||||
mine, oldest = c.remote_get_versions()
|
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):
|
def flush_but_dont_ignore(res):
|
||||||
d = flushEventualQueue()
|
d = flushEventualQueue()
|
||||||
|
@ -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)
|
|
Reference in New Issue
Block a user