summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClark Boylan <clark.boylan@gmail.com>2017-03-28 10:59:47 -0700
committerClark Boylan <clark.boylan@gmail.com>2017-03-28 11:00:16 -0700
commit02228ceb2110a1bc2c484ff1a715dd664740efe2 (patch)
tree6c5c4ef11228c9a9b2740cdb7a268fa9eb7aa566
parentf377238903a54001354f597f55ddf16fc9bb0996 (diff)
downloadpbr-02228ceb2110a1bc2c484ff1a715dd664740efe2.tar.gz
Lazy import pkg_resources
pkg_resources is costly to import so don't import it until we actually need it. Change-Id: I2152b6b3fd47597b5af032e74a840e2f5b89c383
-rw-r--r--pbr/version.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/pbr/version.py b/pbr/version.py
index e775267..474faf1 100644
--- a/pbr/version.py
+++ b/pbr/version.py
@@ -22,8 +22,6 @@ import itertools
import operator
import sys
-import pkg_resources
-
def _is_int(string):
try:
@@ -435,6 +433,9 @@ class VersionInfo(object):
record associated with the package, and if there is no such record
falls back to the logic sdist would use.
"""
+ # Lazy import because pkg_resources is costly to import so defer until
+ # we absolutely need it.
+ import pkg_resources
try:
requirement = pkg_resources.Requirement.parse(self.package)
provider = pkg_resources.get_provider(requirement)