Lazy import pkg_resources

pkg_resources is costly to import so don't import it until we actually
need it.

Change-Id: I2152b6b3fd47597b5af032e74a840e2f5b89c383
This commit is contained in:
Clark Boylan 2017-03-28 10:59:47 -07:00
parent f377238903
commit 02228ceb21

View File

@ -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)