From 8b3925e4d4b97dc28bfc903483ec4793fb38fed5 Mon Sep 17 00:00:00 2001 From: Soren Hansen Date: Fri, 7 Jan 2011 15:17:03 +0100 Subject: [PATCH] Less code generation. --- .bzrignore | 1 + doc/source/conf.py | 5 ++--- nova/version.py | 42 +++++++++++++++++++----------------------- setup.py | 38 ++++---------------------------------- 4 files changed, 26 insertions(+), 60 deletions(-) diff --git a/.bzrignore b/.bzrignore index d81a7d829df7..b271561a3564 100644 --- a/.bzrignore +++ b/.bzrignore @@ -12,3 +12,4 @@ CA/openssl.cnf CA/serial* CA/newcerts/*.pem CA/private/cakey.pem +nova/vcsversion.py diff --git a/doc/source/conf.py b/doc/source/conf.py index 61b3749d06f2..20e9c88afc5e 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -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 # built documents. # -import re from nova import version as nova_version # The full version, including alpha/beta/rc tags. -release = nova_version.string() +release = nova_version.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 # for a list of supported languages. diff --git a/nova/version.py b/nova/version.py index fc14b840119f..1504a5c82fab 100644 --- a/nova/version.py +++ b/nova/version.py @@ -1,35 +1,31 @@ #!/usr/bin/env python -"""This file is automatically generated by generate_version_info -It uses the current working tree to determine the revision. -So don't edit it. :) -""" +try: + from nova.vcsversion import version_info +except ImportError: + version_info = {'branch_nick': u'LOCALBRANCH', + 'revision_id': 'LOCALREVISION', + 'revno': 0} -version_info = {'branch_nick': u'LOCALBRANCH', 'revision_id': 'LOCALREVISION', - 'revno': 0} +NOVA_VERSION = ['2011', '1'] +YEAR, COUNT = NOVA_VERSION -revisions = {} - -file_revisions = {} +FINAL = False # This becomes true at Release Candidate time -if __name__ == '__main__': - 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(): +def canonical_version_string(): return '.'.join([YEAR, COUNT]) +def version_string(): + if FINAL: + return canonical_version_string() + else: + return '%s-dev' % (canonical_version_string(),) + + 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()) +def version_string_with_vcs(): + return "%s-%s" % (canonical_version_string(), vcs_version_string()) diff --git a/setup.py b/setup.py index 6d7cecb70ffe..2ccece78965f 100644 --- a/setup.py +++ b/setup.py @@ -24,44 +24,14 @@ from setuptools.command.sdist import sdist from sphinx.setup_command import BuildDoc from nova.utils import parse_mailmap, str_dict_replace +from nova import version -NOVA_VERSION = ['2011', '1'] - -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'): +if os.path.isdir('.bzr'): + with open("nova/vcsversion.py", 'w') as version_file: vcs_cmd = subprocess.Popen(["bzr", "version-info", "--python"], stdout=subprocess.PIPE) vcsversion = vcs_cmd.communicate()[0] version_file.write(vcsversion) - else: - version_file.write(VERSIONFILE_DEFAULT_VCS_VERSION) - version_file.write(VERSIONFILE_DATA) class local_BuildDoc(BuildDoc): @@ -88,7 +58,7 @@ class local_sdist(sdist): sdist.run(self) setup(name='nova', - version='2011.1', + version=version.canonical_version(), description='cloud computing fabric controller', author='OpenStack', author_email='nova@lists.launchpad.net',