Add get_version script to automate release versions (PEP386 naming)
This commit is contained in:
parent
289730a3e3
commit
4dd6308db9
|
@ -11,3 +11,4 @@ deluge/i18n/*/
|
|||
*.desktop
|
||||
.build_data*
|
||||
osx/app
|
||||
RELEASE-VERSION
|
||||
|
|
29
MANIFEST.in
29
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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
4
setup.py
4
setup.py
|
@ -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",
|
||||
|
|
|
@ -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')
|
Loading…
Reference in New Issue