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)
|
||||
requirements = output.communicate()[0].strip()
|
||||
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_dependency_links
|
||||
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
|
||||
|
||||
|
||||
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):
|
||||
"""Customized sdist hook - builds the ChangeLog file from VC first"""
|
||||
def run(self):
|
||||
@ -97,12 +75,11 @@ try:
|
||||
except:
|
||||
pass
|
||||
|
||||
requires = parse_requirements(['requirements.txt', 'tools/pip-requires'])
|
||||
|
||||
depend_links = parse_dependency_links(['requirements.txt',
|
||||
'tools/pip-requires'])
|
||||
requires = parse_requirements()
|
||||
depend_links = parse_dependency_links()
|
||||
|
||||
write_requirements()
|
||||
write_vcsversion('melange/vcsversion.py')
|
||||
|
||||
setup(name='melange',
|
||||
version=version.canonical_version_string(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user