Let openstack.common handle write_vcsversion().
Change-Id: Id2c494a304fac1b69c1514ac90865b27f49e9881
This commit is contained in:
parent
420e8836a5
commit
73b5726559
|
@ -85,3 +85,28 @@ def write_requirements():
|
||||||
stdout=subprocess.PIPE)
|
stdout=subprocess.PIPE)
|
||||||
requirements = output.communicate()[0].strip()
|
requirements = output.communicate()[0].strip()
|
||||||
req_file.write(requirements)
|
req_file.write(requirements)
|
||||||
|
|
||||||
|
|
||||||
|
def run_git_command(cmd):
|
||||||
|
output = subprocess.Popen(["/bin/sh", "-c", cmd],
|
||||||
|
stdout=subprocess.PIPE)
|
||||||
|
return output.communicate()[0].strip()
|
||||||
|
|
||||||
|
|
||||||
|
def write_vcsversion(location):
|
||||||
|
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 --pretty=oneline"
|
||||||
|
revid = run_git_command(revid_cmd).split()[0]
|
||||||
|
revno_cmd = "git --no-pager log --oneline | wc -l"
|
||||||
|
revno = run_git_command(revno_cmd)
|
||||||
|
with open(location, '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))
|
||||||
|
|
33
setup.py
33
setup.py
|
@ -30,34 +30,12 @@ from melange.openstack.common.setup import parse_mailmap, str_dict_replace
|
||||||
from melange.openstack.common.setup import parse_requirements
|
from melange.openstack.common.setup import parse_requirements
|
||||||
from melange.openstack.common.setup import parse_dependency_links
|
from melange.openstack.common.setup import parse_dependency_links
|
||||||
from melange.openstack.common.setup import write_requirements
|
from melange.openstack.common.setup import write_requirements
|
||||||
|
from melange.openstack.common.setup import write_vcsversion
|
||||||
|
from melange.openstack.common.setup import run_git_command
|
||||||
|
|
||||||
from melange import version
|
from melange 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("melange/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))
|
|
||||||
|
|
||||||
|
|
||||||
class local_sdist(sdist):
|
class local_sdist(sdist):
|
||||||
"""Customized sdist hook - builds the ChangeLog file from VC first"""
|
"""Customized sdist hook - builds the ChangeLog file from VC first"""
|
||||||
def run(self):
|
def run(self):
|
||||||
|
@ -97,12 +75,11 @@ try:
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
requires = parse_requirements(['requirements.txt', 'tools/pip-requires'])
|
requires = parse_requirements()
|
||||||
|
depend_links = parse_dependency_links()
|
||||||
depend_links = parse_dependency_links(['requirements.txt',
|
|
||||||
'tools/pip-requires'])
|
|
||||||
|
|
||||||
write_requirements()
|
write_requirements()
|
||||||
|
write_vcsversion('melange/vcsversion.py')
|
||||||
|
|
||||||
setup(name='melange',
|
setup(name='melange',
|
||||||
version=version.canonical_version_string(),
|
version=version.canonical_version_string(),
|
||||||
|
|
1
tox.ini
1
tox.ini
|
@ -4,6 +4,7 @@ envlist = py26,py27,pep8
|
||||||
[testenv]
|
[testenv]
|
||||||
setenv = VIRTUAL_ENV={envdir}
|
setenv = VIRTUAL_ENV={envdir}
|
||||||
deps = -r{toxinidir}/tools/pip-requires
|
deps = -r{toxinidir}/tools/pip-requires
|
||||||
|
-r{toxinidir}/tools/test-requires
|
||||||
commands = nosetests
|
commands = nosetests
|
||||||
|
|
||||||
[testenv:pep8]
|
[testenv:pep8]
|
||||||
|
|
Loading…
Reference in New Issue