Set client module __version__

According to PEP 396, the version of client library
should be set in xxxclient.__version__, that help
python-openstackclient command "module list" to get
the right plugin module versions.

Change-Id: I74f624e75b5335c657d7bb741435bfafedcc974e
Partial-Bug: #1662058
This commit is contained in:
Rui Chen 2017-02-06 15:10:24 +08:00
parent 62ec81e478
commit 10209c5e52
4 changed files with 37 additions and 5 deletions

View File

@ -1 +1,22 @@
# Copyright 2017 Huawei, Inc. All rights reserved.
#
# 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.
#
"""Barbican Client Library Binding"""
import pbr.version
version_info = pbr.version.VersionInfo("python-barbicanclient")
__version__ = version_info.version_string()

View File

@ -32,9 +32,9 @@ from keystoneauth1 import loading
from keystoneauth1 import session
import six
import barbicanclient
from barbicanclient import client
from barbicanclient._i18n import _LW
from barbicanclient import version
LOG = logging.getLogger(__name__)
@ -60,7 +60,7 @@ class Barbican(app.App):
super(Barbican, self).__init__(
description=__doc__.strip(),
version=version.__version__,
version=barbicanclient.__version__,
command_manager=commandmanager.CommandManager(
'openstack.key_manager.v1'),
deferred_help=True,

View File

@ -1,6 +1,8 @@
import testtools
import barbicanclient
from barbicanclient import base
from barbicanclient import version
class TestValidateRef(testtools.TestCase):
@ -22,3 +24,9 @@ class TestValidateRef(testtools.TestCase):
d3 = base.censored_copy(d1, ['payload'])
self.assertNotEqual(d1, d3, 'd3 has redacted payload value')
self.assertNotEqual(d3['payload'], 'my_key', 'no key in payload')
def test_module_version(self):
self.assertTrue(hasattr(barbicanclient, '__version__'))
# Test forward compatibility, please remove the case when all reference
# switch to barbicanclient.__version__
self.assertTrue(hasattr(version, '__version__'))

View File

@ -17,7 +17,10 @@
Cloudkeep's Barbican Client version
"""
import pbr.version
import barbicanclient
version_info = pbr.version.VersionInfo("python-barbicanclient")
__version__ = version_info.version_string()
# NOTE(RuiChen): According to PEP 396, barbicanclient.version.__version__
# should be deprecated, please use barbicanclient.__version__
# instead.
__version__ = barbicanclient.__version__