diff options
author | Calum Lind <calumlind+deluge@gmail.com> | 2013-05-01 04:52:23 +0200 |
---|---|---|
committer | Calum Lind <calumlind+deluge@gmail.com> | 2013-05-01 06:24:36 +0200 |
commit | 4dd6308db91a38311317ef5bd0f1bbd6788424e1 (patch) | |
tree | 1819e8899cd9335be2ff2a82cd923305b0ed5eed | |
parent | Make sure prioritize first/last doesn't enable pieces in (diff) | |
download | deluge-4dd6308db91a38311317ef5bd0f1bbd6788424e1.tar.xz deluge-4dd6308db91a38311317ef5bd0f1bbd6788424e1.zip |
Add get_version script to automate release versions (PEP386 naming)deluge-2.0.0.dev0
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | MANIFEST.in | 29 | ||||
-rw-r--r-- | deluge/common.py | 36 | ||||
-rw-r--r-- | deluge/core/core.py | 3 | ||||
-rw-r--r-- | setup.cfg | 4 | ||||
-rwxr-xr-x | setup.py | 4 | ||||
-rw-r--r-- | version.py | 70 |
7 files changed, 126 insertions, 21 deletions
diff --git a/.gitignore b/.gitignore index 76d5be39c..4ee1bf4a1 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,4 @@ deluge/i18n/*/ *.desktop .build_data* osx/app +RELEASE-VERSION diff --git a/MANIFEST.in b/MANIFEST.in index d207fb6d8..8aa66040e 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,12 +1,23 @@ -recursive-include docs/man * -recursive-include deluge * -recursive-include win32 * +include AUTHORS ChangeLog DEPENDS ez_setup.py LICENSE msgfmt.py RELEASE-VERSION version.py +graft docs/man -recursive-exclude deluge *.egg-link -exclude deluge/ui/web/gen_gettext.py +include deluge/i18n/*.po + +graft deluge/plugins +recursive-exclude deluge/plugins create_dev_link.sh *.pyc + +prune deluge/tests +graft deluge/ui/data +graft deluge/ui/gtkui/glade + +include deluge/ui/web/index.html +include deluge/ui/web/gettext.js +include deluge/ui/web/css/*.css exclude deluge/ui/web/css/*-debug.css -exclude deluge/ui/web/js/build.sh -exclude deluge/ui/web/js/Deluge*.js +include deluge/ui/web/js/*.js exclude deluge/ui/web/js/*-debug.js -prune deluge/ui/web/docs -prune deluge/scripts +exclude deluge/ui/web/gen_gettext.py +graft deluge/ui/web/themes +graft deluge/ui/web/render +graft deluge/ui/web/icons +graft deluge/ui/web/images diff --git a/deluge/common.py b/deluge/common.py index c7d161b16..8c655ec07 100644 --- a/deluge/common.py +++ b/deluge/common.py @@ -685,16 +685,36 @@ class VersionSplit(object): """ def __init__(self, ver): - ver = ver.lower() - vs = ver.replace("_", "-").split("-") + import re + VERSION_RE = re.compile(r''' + ^ + (?P<version>\d+\.\d+) # minimum 'N.N' + (?P<extraversion>(?:\.\d+)*) # any number of extra '.N' segments + (?: + (?P<prerel>[abc]|rc) # 'a'=alpha, 'b'=beta, 'c'=release candidate + # 'rc'= alias for release candidate + (?P<prerelversion>\d+(?:\.\d+)*) + )? + (?P<postdev>(\.post(?P<post>\d+))?(\.dev(?P<dev>\d+))?)? + $''', re.VERBOSE) + + # Check for PEP 386 compliant version + match = re.search(VERSION_RE, ver) + if match: + group = [(x if x is not None else '') for x in match.group(1,2,3,4,8)] + vs = [''.join(group[0:2]),''.join(group[2:4]), group[4].lstrip('.')] + else: + ver = ver.lower() + vs = ver.replace("_", "-").split("-") + self.version = [int(x) for x in vs[0].split(".")] self.suffix = None self.dev = False if len(vs) > 1: - if vs[1].startswith(("rc", "alpha", "beta")): + if vs[1].startswith(("rc", "a", "b", "c")): self.suffix = vs[1] - if vs[-1] == 'dev': - self.dev = True + if vs[-1].startswith('dev'): + self.dev = vs[-1] def __cmp__(self, ver): """ @@ -704,6 +724,12 @@ class VersionSplit(object): :type ver: VersionSplit """ + # PEP 386 versions with .devN precede release version + if (bool(self.dev) != bool(ver.dev)): + if self.dev != 'dev': + self.dev = not self.dev + if ver.dev != 'dev': + ver.dev = not ver.dev # If there is no suffix we use z because we want final # to appear after alpha, beta, and rc alphabetically. diff --git a/deluge/core/core.py b/deluge/core/core.py index eff6849b9..b97e3aded 100644 --- a/deluge/core/core.py +++ b/deluge/core/core.py @@ -76,8 +76,7 @@ class Core(component.Component): log.info("Starting libtorrent %s session..", lt.version) # Create the client fingerprint - version = [int(value.split("-")[0]) for value in - deluge.common.get_version().split(".")] + version = deluge.common.VersionSplit(deluge.common.get_version()).version while len(version) < 4: version.append(0) @@ -1,7 +1,3 @@ -[egg_info] -tag_build = -dev -tag_svn_revision = false - [build_docs] source-dir = docs/source build-dir = docs/build @@ -35,6 +35,8 @@ import platform import msgfmt import glob +from version import get_version + from distutils import cmd, sysconfig from distutils.command.build import build as _build from distutils.command.clean import clean as _clean @@ -327,7 +329,7 @@ if windows_check(): # Main setup setup( name = "deluge", - version = "1.3.900", + version = get_version(prefix='deluge-', suffix='.dev0'), fullname = "Deluge Bittorrent Client", description = "Bittorrent Client", author = "Andrew Resch, Damien Churchill", diff --git a/version.py b/version.py new file mode 100644 index 000000000..f20fc4863 --- /dev/null +++ b/version.py @@ -0,0 +1,70 @@ +# -*- coding: utf-8 -*- +# Authors: Douglas Creager <dcreager@dcreager.net> +# Calum Lind <calumlind@gmail.com> +# +# This file is placed into the public domain. +# +# Calculates the current version number by first checking output of “git describe”, +# modified to conform to PEP 386 versioning scheme. If “git describe” fails +# (likely due to using release tarball rather than git working copy), then fall +# back on reading the contents of the RELEASE-VERSION file. +# +# Usage: Import in setup.py, and use result of get_version() as package version: +# +# from version import * +# +# setup( +# ... +# version=get_version(), +# ... +# ) +# +# Script will automatically update the RELEASE-VERSION file, if needed. +# Note that RELEASE-VERSION file should *not* be checked into git; please add +# it to your top-level .gitignore file. +# +# You'll probably want to distribute the RELEASE-VERSION file in your +# sdist tarballs; to do this, just create a MANIFEST.in file that +# contains the following line: +# +# include RELEASE-VERSION +# + +__all__ = ("get_version") + +from subprocess import Popen, PIPE +VERSION_FILE = "RELEASE-VERSION" + +def call_git_describe(prefix='', suffix=''): + cmd = 'git describe --tags --match %s[0-9]*' % prefix + try: + version = Popen(cmd.split(), stdout=PIPE).communicate()[0] + version = version.strip().replace(prefix, '') + if '-' in version: + version = '.dev'.join(version.replace(suffix,'').split('-')[:2]) + return version + except: + return None + +def get_version(prefix='', suffix=''): + try: + with open(VERSION_FILE, "r") as f: + release_version = f.readline().strip() + except: + release_version = None + + version = call_git_describe(prefix, suffix) + + if version is None: + version = release_version + if version is None: + raise ValueError("Cannot find the version number!") + + if version != release_version: + with open(VERSION_FILE, "w") as f: + f.write("%s\n" % version) + + return version + +if __name__ == "__main__": + print get_version(prefix='deluge-', suffix='.dev0') |