Less code generation.

This commit is contained in:
Soren Hansen 2011-01-07 15:17:03 +01:00
parent 9b35abf294
commit 8b3925e4d4
4 changed files with 26 additions and 60 deletions

View File

@ -12,3 +12,4 @@ CA/openssl.cnf
CA/serial* CA/serial*
CA/newcerts/*.pem CA/newcerts/*.pem
CA/private/cakey.pem CA/private/cakey.pem
nova/vcsversion.py

View File

@ -60,12 +60,11 @@ copyright = u'2010, United States Government as represented by the Administrator
# |version| and |release|, also used in various other places throughout the # |version| and |release|, also used in various other places throughout the
# built documents. # built documents.
# #
import re
from nova import version as nova_version from nova import version as nova_version
# The full version, including alpha/beta/rc tags. # The full version, including alpha/beta/rc tags.
release = nova_version.string() release = nova_version.version()
# The short X.Y version. # The short X.Y version.
version = re.sub(r'-dev$', '', nova_version.string()) version = nova_version.canonical_version()
# The language for content autogenerated by Sphinx. Refer to documentation # The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages. # for a list of supported languages.

View File

@ -1,35 +1,31 @@
#!/usr/bin/env python #!/usr/bin/env python
"""This file is automatically generated by generate_version_info try:
It uses the current working tree to determine the revision. from nova.vcsversion import version_info
So don't edit it. :) except ImportError:
""" version_info = {'branch_nick': u'LOCALBRANCH',
'revision_id': 'LOCALREVISION',
'revno': 0}
version_info = {'branch_nick': u'LOCALBRANCH', 'revision_id': 'LOCALREVISION', NOVA_VERSION = ['2011', '1']
'revno': 0} YEAR, COUNT = NOVA_VERSION
revisions = {} FINAL = False # This becomes true at Release Candidate time
file_revisions = {}
if __name__ == '__main__': def canonical_version_string():
print 'revision: %(revno)d' % version_info
print 'nick: %(branch_nick)s' % version_info
print 'revision id: %(revision_id)s' % version_info
# below this line automatically generated by setup.py
YEAR = '2011'
COUNT = '1-dev'
def string():
return '.'.join([YEAR, COUNT]) return '.'.join([YEAR, COUNT])
def version_string():
if FINAL:
return canonical_version_string()
else:
return '%s-dev' % (canonical_version_string(),)
def vcs_version_string(): def vcs_version_string():
return "%s:%s" % (version_info['branch_nick'], version_info['revision_id']) return "%s:%s" % (version_info['branch_nick'], version_info['revision_id'])
def string_with_vcs(): def version_string_with_vcs():
return "%s-%s" % (string(), vcs_version_string()) return "%s-%s" % (canonical_version_string(), vcs_version_string())

View File

@ -24,44 +24,14 @@ from setuptools.command.sdist import sdist
from sphinx.setup_command import BuildDoc from sphinx.setup_command import BuildDoc
from nova.utils import parse_mailmap, str_dict_replace from nova.utils import parse_mailmap, str_dict_replace
from nova import version
NOVA_VERSION = ['2011', '1'] if os.path.isdir('.bzr'):
with open("nova/vcsversion.py", 'w') as version_file:
VERSIONFILE_DEFAULT_VCS_VERSION = """
version_info = {"branch_nick": "LOCALBRANCH", "revision_id": "LOCALREVISION"}
"""
VERSIONFILE_DATA = """
# below this line automatically generated by setup.py
YEAR = %r
COUNT = %r
""" % (NOVA_VERSION[0], NOVA_VERSION[1])
VERSIONFILE_DATA += """
def string():
return '.'.join([YEAR, COUNT])
def vcs_version_string():
return "%s:%s" % (version_info['branch_nick'], version_info['revision_id'])
def string_with_vcs():
return "%s-%s" % (string(), vcs_version_string())
"""
with open("nova/version.py", 'w') as version_file:
if os.path.isdir('.bzr'):
vcs_cmd = subprocess.Popen(["bzr", "version-info", "--python"], vcs_cmd = subprocess.Popen(["bzr", "version-info", "--python"],
stdout=subprocess.PIPE) stdout=subprocess.PIPE)
vcsversion = vcs_cmd.communicate()[0] vcsversion = vcs_cmd.communicate()[0]
version_file.write(vcsversion) version_file.write(vcsversion)
else:
version_file.write(VERSIONFILE_DEFAULT_VCS_VERSION)
version_file.write(VERSIONFILE_DATA)
class local_BuildDoc(BuildDoc): class local_BuildDoc(BuildDoc):
@ -88,7 +58,7 @@ class local_sdist(sdist):
sdist.run(self) sdist.run(self)
setup(name='nova', setup(name='nova',
version='2011.1', version=version.canonical_version(),
description='cloud computing fabric controller', description='cloud computing fabric controller',
author='OpenStack', author='OpenStack',
author_email='nova@lists.launchpad.net', author_email='nova@lists.launchpad.net',