summaryrefslogtreecommitdiffstats
path: root/openstack
diff options
context:
space:
mode:
authorMonty Taylor <mordred@inaugust.com>2013-01-25 08:12:28 +1100
committerMonty Taylor <mordred@inaugust.com>2013-01-25 08:12:28 +1100
commit5e69dd94bf81f55d6d5b917b7ec673482b5565c0 (patch)
tree2826a9948a025ddce4ce569a5c3cc5aec6330192 /openstack
parent416e92d728b351a5ffbbbf0dda4973d41b1a7947 (diff)
downloadoslo-5e69dd94bf81f55d6d5b917b7ec673482b5565c0.tar.gz
oslo-5e69dd94bf81f55d6d5b917b7ec673482b5565c0.tar.xz
oslo-5e69dd94bf81f55d6d5b917b7ec673482b5565c0.zip
Support running uninstalled in a tarball dir.
Running tests from the directory of an expanded tarball is a reasonable thing to do, so support it by checking for PKG-INFO file if the pkg_resources version grab fails. Fixes bug 1103473 Change-Id: I2bf1fc39b070d3a2cdf6a3abe5e816c81d2916a0
Diffstat (limited to 'openstack')
-rw-r--r--openstack/common/version.py13
1 files changed, 10 insertions, 3 deletions
diff --git a/openstack/common/version.py b/openstack/common/version.py
index 3653ad0..c27095a 100644
--- a/openstack/common/version.py
+++ b/openstack/common/version.py
@@ -36,9 +36,16 @@ class VersionInfo(object):
def _get_version_from_pkg_resources(self):
"""Get the version of the package from the pkg_resources record
associated with the package."""
- requirement = pkg_resources.Requirement.parse(self.package)
- provider = pkg_resources.get_provider(requirement)
- return provider.version
+ try:
+ requirement = pkg_resources.Requirement.parse(self.package)
+ provider = pkg_resources.get_provider(requirement)
+ return provider.version
+ except pkg_resources.DistributionNotFound:
+ # The most likely cause for this is running tests in a tree with
+ # produced from a tarball where the package itself has not been
+ # installed into anything. Check for a PKG-INFO file.
+ from openstack.common import setup
+ return setup.get_version_from_pkg_info(self.package)
def release_string(self):
"""Return the full version of the package including suffixes indicating