diff --git a/requirements.txt b/requirements.txt index dae7525cdb..113986693f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,3 @@ -pbr>=0.5.21,<1.0 dnspython>=1.9.4 eventlet>=0.9.15 greenlet>=0.3.1 diff --git a/swift/__init__.py b/swift/__init__.py index 7e8fb7b8dc..9d0e8896f7 100644 --- a/swift/__init__.py +++ b/swift/__init__.py @@ -16,13 +16,22 @@ import os import gettext -import pbr.version - - -_version_info = pbr.version.VersionInfo('swift') -__version__ = _version_info.release_string() -__canonical_version__ = _version_info.version_string() +import pkg_resources +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__ = __canonical_version__ = pkg_resources.get_provider( + pkg_resources.Requirement.parse('swift')).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_info = pbr.version.VersionInfo('swift') + __version__ = _version_info.release_string() + __canonical_version__ = _version_info.version_string() _localedir = os.environ.get('SWIFT_LOCALEDIR') _t = gettext.translation('swift', localedir=_localedir, fallback=True)