Convert glance to glance/openstack/common/setup.py
Convert glance to use glance/openstack/common/setup.py to write the changelog. Change-Id: Ibadec15d7e530149cf62cd00d63c06bf63cf53bb Signed-off-by: Chuck Short <chuck.short@canonical.com>
This commit is contained in:
parent
bdcb63d46d
commit
bcb6089733
@ -5,6 +5,7 @@ include AUTHORS
|
||||
include run_tests.py
|
||||
include HACKING.rst
|
||||
include LICENSE
|
||||
include ChangeLog
|
||||
include babel.cfg tox.ini
|
||||
include glance/locale/glance.pot
|
||||
include glance/registry/db/migrate_repo/README
|
||||
|
43
setup.py
43
setup.py
@ -22,53 +22,21 @@ from setuptools import setup, find_packages
|
||||
from setuptools.command.sdist import sdist
|
||||
|
||||
from glance.openstack.common.setup import generate_authors
|
||||
from glance.openstack.common.setup import parse_requirements
|
||||
from glance.openstack.common.setup import parse_dependency_links
|
||||
from glance.openstack.common.setup import parse_requirements
|
||||
from glance.openstack.common.setup import write_git_changelog
|
||||
from glance.openstack.common.setup import write_vcsversion
|
||||
|
||||
gettext.install('glance', unicode=1)
|
||||
|
||||
from glance 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("glance/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):
|
||||
if os.path.isdir('.bzr'):
|
||||
# We're in a bzr branch
|
||||
|
||||
log_cmd = subprocess.Popen(["bzr", "log", "--gnu"],
|
||||
stdout=subprocess.PIPE)
|
||||
changelog = log_cmd.communicate()[0]
|
||||
with open("ChangeLog", "w") as changelog_file:
|
||||
changelog_file.write(changelog)
|
||||
write_git_changelog()
|
||||
generate_authors()
|
||||
sdist.run(self)
|
||||
|
||||
cmdclass = {'sdist': local_sdist}
|
||||
|
||||
# If Sphinx is installed on the box running setup.py,
|
||||
@ -90,6 +58,9 @@ except:
|
||||
|
||||
requires = parse_requirements()
|
||||
depend_links = parse_dependency_links()
|
||||
write_vcsversion('glance/vcsversion.py')
|
||||
|
||||
from glance import version
|
||||
|
||||
setup(
|
||||
name='glance',
|
||||
|
Loading…
x
Reference in New Issue
Block a user