From 7d61c543993638caf5dbe176ed6c077ee506d87e Mon Sep 17 00:00:00 2001 From: Samuel Merritt Date: Tue, 8 Oct 2013 14:16:32 -0700 Subject: Make pbr only a build-time dependency. This lets you build python-swiftclient packages that don't require pbr to be installed at all. You would need pbr on the machine running rpmbuild / debuild, but not on the machines that install the packages. Unfortunately, this does not make python-swiftclient able to be installed via pip 0.3.1 on Lucid; you'll need to uninstall the system python-pip package and install a new pip some other way. Given that pip < 1.3 doesn't perform SSL certificate validation for pypi (trivial MITM attack, anyone?), you'd probably want to get a new pip anyway. Change-Id: I85d4d77aacf094e48d39e48e750594b95dbc7af0 --- bin/swift | 4 ++-- doc/source/conf.py | 6 +++--- requirements.txt | 1 - swiftclient/__init__.py | 2 +- swiftclient/version.py | 15 +++++++++++++-- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/bin/swift b/bin/swift index 4d11bae..0de5fbe 100755 --- a/bin/swift +++ b/bin/swift @@ -36,7 +36,7 @@ from swiftclient import Connection, HTTPException from swiftclient.utils import config_true_value from swiftclient.multithreading import MultiThreadingManager from swiftclient.exceptions import ClientException -from swiftclient.version import version_info +from swiftclient import __version__ as client_version def get_conn(options): @@ -1262,7 +1262,7 @@ adding "-V 2" is necessary for this.'''.strip('\n')) if __name__ == '__main__': - version = version_info.version_string() + version = client_version parser = OptionParser(version='%%prog %s' % version, usage=''' usage: %%prog [--version] [--help] [--snet] [--verbose] diff --git a/doc/source/conf.py b/doc/source/conf.py index 356b89e..19bc85c 100644 --- a/doc/source/conf.py +++ b/doc/source/conf.py @@ -57,9 +57,9 @@ copyright = u'2013 OpenStack, LLC.' # |version| and |release|, also used in various other places throughout the # built documents. # -from swiftclient.version import version_info as swiftclient_version -release = swiftclient_version.version_string() -version = swiftclient_version.version_string() +import swiftclient.version +release = swiftclient.version.version_string +version = swiftclient.version.version_string # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. diff --git a/requirements.txt b/requirements.txt index 42104ec..519b048 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1 @@ -pbr>=0.5.21,<1.0 simplejson>=2.0.9 diff --git a/swiftclient/__init__.py b/swiftclient/__init__.py index 1d74249..c4b7d45 100644 --- a/swiftclient/__init__.py +++ b/swiftclient/__init__.py @@ -27,6 +27,6 @@ from .client import * try: from swiftclient import version - __version__ = version.version_info.cached_version_string() + __version__ = version.version_string except Exception: pass diff --git a/swiftclient/version.py b/swiftclient/version.py index 7bb5d18..494d6ec 100644 --- a/swiftclient/version.py +++ b/swiftclient/version.py @@ -14,6 +14,17 @@ # License for the specific language governing permissions and limitations # under the License. -from pbr import version as pbr_version +import pkg_resources -version_info = pbr_version.VersionInfo('python-swiftclient') +try: + # First, try to get our version out of PKG-INFO. If we're installed, + # this'll let us find our version without pulling in pbr. After all, if + # we're installed on a system, we're not in a Git-managed source tree, so + # pbr doesn't really buy us anything. + version_string = pkg_resources.get_provider( + pkg_resources.Requirement.parse('python-swiftclient')).version +except pkg_resources.DistributionNotFound: + # No PKG-INFO? We're probably running from a checkout, then. Let pbr do + # its thing to figure out a version number. + import pbr.version + version_string = str(pbr.version.VersionInfo('python-swiftclient')) -- cgit v1.2.1