Handle missing pkg_resources package

This commit is contained in:
Pedro Algarvio 2018-10-08 18:46:51 +01:00
parent 99c5dbadd1
commit b1c292860d
No known key found for this signature in database
GPG key ID: BB36BF6584A298FF

View file

@ -23,7 +23,11 @@ requisite to a pkg.installed state for the package which provides pip
from __future__ import absolute_import, print_function, unicode_literals
import re
import logging
import pkg_resources
try:
import pkg_resources
HAS_PKG_RESOURCES = True
except ImportError:
HAS_PKG_RESOURCES = False
# Import salt libs
import salt.utils.versions
@ -71,6 +75,8 @@ def __virtual__():
'''
Only load if the pip module is available in __salt__
'''
if HAS_PKG_RESOURCES is False:
return False, 'The pkg_resources python library is not installed'
if 'pip.list' in __salt__:
return __virtualname__
return False