Base version.py on glance.

This makes setting and calculating the versioning of quantum more
like other OpenStack projects, simplifying the work of the CI
and Release Management teams.

Addresses bug 916018 which prevents the quantum-tarball job from
running correctly.

Change-Id: I5b006ccc3d31c5d213c703853dfa38f04d983918
This commit is contained in:
James E. Blair 2012-01-17 08:02:10 +11:00
parent d5414390df
commit b11971933a
2 changed files with 29 additions and 2 deletions

1
.gitignore vendored
View File

@ -7,3 +7,4 @@ run_tests.log
tests/
.quantum-venv/
.venv/
quantum/vcsversion.py

View File

@ -6,11 +6,37 @@ except ImportError:
from setuptools import setup, find_packages
import sys
import version
import os
import subprocess
from quantum import version
def run_git_command(cmd):
output = subprocess.Popen(["/bin/sh", "-c", cmd],
stdout=subprocess.PIPE)
return output.communicate()[0].strip()
if os.path.isdir('.git'):
branch_nick_cmd = 'git branch | grep -Ei "\* (.*)" | cut -f2 -d" "'
branch_nick = run_git_command(branch_nick_cmd)
revid_cmd = "git --no-pager log --max-count=1 | cut -f2 -d' ' | head -1"
revid = run_git_command(revid_cmd)
revno_cmd = "git --no-pager log --oneline | wc -l"
revno = run_git_command(revno_cmd)
with open("quantum/vcsversion.py", 'w') as version_file:
version_file.write("""
# This file is automatically generated by setup.py, So don't edit it. :)
version_info = {
'branch_nick': '%s',
'revision_id': '%s',
'revno': %s
}
""" % (branch_nick, revid, revno))
Name = 'quantum'
Url = "https://launchpad.net/quantum"
Version = version.get_git_version()
Version = version.canonical_version_string()
License = 'Apache License 2.0'
Author = 'Netstack'
AuthorEmail = 'netstack@lists.launchpad.net'