Merge pull request #49938 from s0undt3ch/2018.3

Handle missing `pkg_resources` package
This commit is contained in:
Nicole Thomas 2018-10-09 09:41:09 -04:00 committed by GitHub
commit 614d1720b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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