Split version code into its own file.

Change-Id: I764035afc257fad38b9d40d157ec1a9d41a40a6f
This commit is contained in:
Monty Taylor 2011-12-06 14:41:30 -08:00
parent 0d8bc57233
commit 4956a936d9
6 changed files with 43 additions and 30 deletions

View File

@ -35,14 +35,14 @@ if os.path.exists(os.path.join(possible_topdir, 'keystone', '__init__.py')):
sys.path.insert(0, possible_topdir)
import keystone.tools.tracer # @UnusedImport # module runs on import
import keystone
from keystone import version
from keystone.common import config
if __name__ == '__main__':
# Initialize a parser for our configuration paramaters
# since we have special handling for --admin-port argument
parser = optparse.OptionParser(version='%%prog %s' % keystone.version)
parser = optparse.OptionParser(version='%%prog %s' % version.version())
common_group = config.add_common_options(parser)
config.add_log_options(parser)

View File

@ -17,25 +17,7 @@ import optparse
import sys
from keystone.common import config, wsgi
API_VERSION = "2.0"
API_VERSION_STATUS = "beta"
API_VERSION_DATE = "2011-11-19T00:00:00Z"
RELEASE_VERSION = "2012.1"
RELEASE_VERSION_FINAL = False # becomes true at Release Candidate time
def canonical_version():
return RELEASE_VERSION
def version():
if RELEASE_VERSION_FINAL:
return RELEASE_VERSION
else:
return '%s-dev' % (RELEASE_VERSION)
from keystone import version
# This installs the _(...) function as a built-in so all other modules
@ -74,7 +56,7 @@ class Server():
if options is None or args is None:
# Initialize a parser for our configuration paramaters
parser = optparse.OptionParser(version='%%prog %s' %
version)
version.version())
common_group = config.add_common_options(parser)
config.add_log_options(parser)

View File

@ -7,7 +7,7 @@ possible_topdir = os.path.normpath(os.path.join(os.path.dirname(__file__),
os.pardir,
os.pardir))
import keystone
from keystone import version
from keystone import utils
from keystone.common import template, wsgi
@ -37,8 +37,8 @@ class VersionController(wsgi.Controller):
resp.unicode_body = template.template(resp_file,
HOST=hostname,
PORT=port,
API_VERSION=keystone.API_VERSION,
API_VERSION_STATUS=keystone.API_VERSION_STATUS,
API_VERSION_DATE=keystone.API_VERSION_DATE)
API_VERSION=version.API_VERSION,
API_VERSION_STATUS=version.API_VERSION_STATUS,
API_VERSION_DATE=version.API_VERSION_DATE)
return resp

View File

@ -26,7 +26,7 @@ import sys
import logging
import optparse # deprecated in 2.7, in favor of argparse
import keystone
from keystone import version
from keystone.common import config
from keystone.manage import api
import keystone.backends as db
@ -75,7 +75,7 @@ def parse_args(args=None):
# Initialize a parser for our configuration paramaters
parser = RaisingOptionParser(usage, version='%%prog %s'
% keystone.version())
% version.version())
_common_group = config.add_common_options(parser)
config.add_log_options(parser)

31
keystone/version.py Normal file
View File

@ -0,0 +1,31 @@
# Copyright (C) 2011 OpenStack LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
API_VERSION = "2.0"
API_VERSION_STATUS = "beta"
API_VERSION_DATE = "2011-11-19T00:00:00Z"
RELEASE_VERSION = "2012.1"
RELEASE_VERSION_FINAL = False # becomes true at Release Candidate time
def canonical_version():
return RELEASE_VERSION
def version():
if RELEASE_VERSION_FINAL:
return RELEASE_VERSION
else:
return '%s-dev' % (RELEASE_VERSION)

View File

@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
import keystone
from keystone import version
import os
import subprocess
import sys
@ -51,7 +51,7 @@ if sys.version_info < (2, 6):
setup(
name='keystone',
version=keystone.canonical_version(),
version=version.canonical_version(),
description="Authentication service - proposed for OpenStack",
license='Apache License (2.0)',
classifiers=["Programming Language :: Python"],