diff --git a/salt/states/pip_state.py b/salt/states/pip_state.py index 3238078014..c6d09f91e3 100644 --- a/salt/states/pip_state.py +++ b/salt/states/pip_state.py @@ -41,14 +41,18 @@ except ImportError: if HAS_PIP is True: try: - import pip.req + from pip.req import InstallRequirement except ImportError: - HAS_PIP = False - # Remove references to the loaded pip module above so reloading works - import sys - del pip - if 'pip' in sys.modules: - del sys.modules['pip'] + # pip 10.0.0 move req module under pip._internal + try: + from pip._internal.req import InstallRequirement + except: + HAS_PIP = False + # Remove references to the loaded pip module above so reloading works + import sys + del pip + if 'pip' in sys.modules: + del sys.modules['pip'] try: from pip.exceptions import InstallationError @@ -129,7 +133,7 @@ def _check_pkg_version_format(pkg): logger.debug( 'Installed pip version: {0}'.format(pip.__version__) ) - install_req = pip.req.InstallRequirement.from_line(pkg) + install_req = InstallRequirement.from_line(pkg) except AttributeError: logger.debug('Installed pip version is lower than 1.2') supported_vcs = ('git', 'svn', 'hg', 'bzr') @@ -137,12 +141,12 @@ def _check_pkg_version_format(pkg): for vcs in supported_vcs: if pkg.startswith(vcs): from_vcs = True - install_req = pip.req.InstallRequirement.from_line( + install_req = InstallRequirement.from_line( pkg.split('{0}+'.format(vcs))[-1] ) break else: - install_req = pip.req.InstallRequirement.from_line(pkg) + install_req = InstallRequirement.from_line(pkg) except (ValueError, InstallationError) as exc: ret['result'] = False if not from_vcs and '=' in pkg and '==' not in pkg: