Make version.py handle pbr not being installed

Since pbr is now only a dev/build-time requirement of taskflow
and not a run-time or test-time requirement we should not have
a version file that explicitly requires pbr to exist to function
correctly.

To accommodate when pbr is not found use the pkg_resources function
that can provide the installed version instead so that we still
provide back a valid version.

Change-Id: Id191d2b38def54b95a3467b4023a9540c284660d
This commit is contained in:
Joshua Harlow 2014-09-01 09:48:21 -07:00 committed by Joshua Harlow
parent 45427dce0e
commit 1eabee4c8b
1 changed files with 8 additions and 6 deletions

View File

@ -14,17 +14,19 @@
# License for the specific language governing permissions and limitations
# under the License.
from pbr import version as pbr_version
import pkg_resources
TASK_VENDOR = "OpenStack Foundation"
TASK_PRODUCT = "OpenStack TaskFlow"
TASK_PACKAGE = None # OS distro package version suffix
version_info = pbr_version.VersionInfo('taskflow')
def version_string():
return version_info.version_string()
try:
from pbr import version as pbr_version
_version_info = pbr_version.VersionInfo('taskflow')
version_string = _version_info.version_string
except ImportError:
_version_info = pkg_resources.get_distribution('taskflow')
version_string = lambda: _version_info.version
def version_string_with_package():