From 02228ceb2110a1bc2c484ff1a715dd664740efe2 Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Tue, 28 Mar 2017 10:59:47 -0700 Subject: [PATCH] Lazy import pkg_resources pkg_resources is costly to import so don't import it until we actually need it. Change-Id: I2152b6b3fd47597b5af032e74a840e2f5b89c383 --- pbr/version.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pbr/version.py b/pbr/version.py index e7752675..474faf16 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)