]> review.fuel-infra Code Review - openstack-build/heat-build.git/commitdiff
Update to latest oslo-version code.
authorMonty Taylor <mordred@inaugust.com>
Sun, 3 Feb 2013 22:29:49 +0000 (09:29 +1100)
committerMonty Taylor <mordred@inaugust.com>
Mon, 4 Feb 2013 00:23:40 +0000 (11:23 +1100)
This pulls in the bugfix patch that handles the usecase wher a packager
running tests from a tarball.

Change-Id: I38cadc5ceaf880f632a0f7ed4d5e9a51c9ddc4e5

heat/openstack/common/version.py

index 3653ad0d0e68657362741f4f2549beac16371f0b..6dd124a903683283820e8567f618cfca420351c3 100644 (file)
@@ -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 heat.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