Latest setup goodness.

Upgrade the common setup code to the latest versions, and use setuptools-git
for sdist tarball generation.

Change-Id: I81eca9199b7d330ef8ec80482565a75f8475a78c
This commit is contained in:
Monty Taylor 2012-07-11 10:44:36 -05:00
parent cf8613e76d
commit c315c5274f
5 changed files with 34 additions and 30 deletions

View File

@ -1,9 +1,5 @@
include AUTHORS
include HACKING.rst README.rst
include LICENSE
include ChangeLog
include run_tests.sh
include openstack-common.conf tox.ini
include glanceclient/versioninfo
recursive-include tests *
recursive-include tools *
exclude .gitignore
exclude .gitreview

View File

@ -35,7 +35,8 @@ def parse_mailmap(mailmap='.mailmap'):
for l in fp:
l = l.strip()
if not l.startswith('#') and ' ' in l:
canonical_email, alias = l.split(' ')
canonical_email, alias = [x for x in l.split(' ')
if x.startswith('<')]
mapping[alias] = canonical_email
return mapping
@ -126,6 +127,13 @@ def _run_shell_command(cmd):
return out[0].strip()
def _get_git_branch_name():
branch_ref = _run_shell_command("git symbolic-ref -q HEAD")
if branch_ref is None:
return "HEAD"
return branch_ref[len("refs/heads/"):]
def _get_git_next_version_suffix(branch_name):
datestamp = datetime.datetime.now().strftime('%Y%m%d')
if branch_name == 'milestone-proposed':
@ -136,10 +144,16 @@ def _get_git_next_version_suffix(branch_name):
milestone_cmd = "git show meta/openstack/release:%s" % branch_name
milestonever = _run_shell_command(milestone_cmd)
if not milestonever:
milestonever = ""
milestonever = branch_name
post_version = _get_git_post_version()
revno = post_version.split(".")[-1]
return "%s~%s.%s%s" % (milestonever, datestamp, revno_prefix, revno)
# post version should look like:
# 0.1.1.4.cc9e28a
# where the bit after the last . is the short sha, and the bit between
# the last and second to last is the revno count
(revno, sha) = post_version.split(".")[-2:]
first_half = "%(milestonever)s~%(datestamp)s" % locals()
second_half = "%(revno_prefix)s%(revno)s.%(sha)s" % locals()
return ".".join((first_half, second_half))
def _get_git_current_tag():
@ -161,11 +175,14 @@ def _get_git_post_version():
cmd = "git --no-pager log --oneline"
out = _run_shell_command(cmd)
revno = len(out.split("\n"))
sha = _run_shell_command("git describe --always")
else:
tag_infos = tag_info.split("-")
base_version = "-".join(tag_infos[:-2])
revno = tag_infos[-2]
return "%s.%s" % (base_version, revno)
(revno, sha) = tag_infos[-2:]
# git describe prefixes the sha with a g
sha = sha[1:]
return "%s.%s.%s" % (base_version, revno, sha)
def write_git_changelog():
@ -207,7 +224,7 @@ _rst_template = """%(heading)s
def read_versioninfo(project):
"""Read the versioninfo file. If it doesn't exist, we're in a github
zipball, and there's really know way to know what version we really
zipball, and there's really no way to know what version we really
are, but that should be ok, because the utility of that should be
just about nil if this code path is in use in the first place."""
versioninfo_path = os.path.join(project, 'versioninfo')
@ -302,17 +319,9 @@ def get_cmdclass():
return cmdclass
def get_git_branchname():
for branch in _run_shell_command("git branch --color=never").split("\n"):
if branch.startswith('*'):
_branch_name = branch.split()[1].strip()
if _branch_name == "(no":
_branch_name = "no-branch"
return _branch_name
def get_pre_version(projectname, base_version):
"""Return a version which is based"""
"""Return a version which is leading up to a version that will
be released in the future."""
if os.path.isdir('.git'):
current_tag = _get_git_current_tag()
if current_tag is not None:
@ -320,14 +329,14 @@ def get_pre_version(projectname, base_version):
else:
branch_name = os.getenv('BRANCHNAME',
os.getenv('GERRIT_REFNAME',
get_git_branchname()))
_get_git_branch_name()))
version_suffix = _get_git_next_version_suffix(branch_name)
version = "%s~%s" % (base_version, version_suffix)
write_versioninfo(projectname, version)
return version.split('~')[0]
return version
else:
version = read_versioninfo(projectname)
return version.split('~')[0]
return version
def get_post_version(projectname):

View File

@ -40,6 +40,7 @@ setuptools.setup(
install_requires=requires,
dependency_links=dependency_links,
tests_require=tests_require,
setup_requires=['setuptools-git>=0.4'],
test_suite="nose.collector",
entry_points={'console_scripts': ['glance = glanceclient.shell:main']},
)

View File

@ -6,4 +6,5 @@ nose-exclude
nosexcover
openstack.nose_plugin
pep8==1.2
setuptools-git>=0.4
sphinx>=1.1.2

View File

@ -13,11 +13,8 @@ deps = -r{toxinidir}/tools/pip-requires
-r{toxinidir}/tools/test-requires
commands = nosetests {posargs}
[tox:jenkins]
downloadcache = ~/cache/pip
[testenv:pep8]
commands = pep8 --repeat --show-source --exclude=.venv,.tox,dist,doc .
commands = pep8 --repeat --show-source --exclude=.venv,.tox,dist,doc,*egg .
[testenv:cover]
setenv = NOSE_WITH_COVERAGE=1