From effe8b9432df01b12bba97b9646103eb19b62a64 Mon Sep 17 00:00:00 2001 From: Erik Johnson Date: Wed, 3 May 2017 12:04:35 -0500 Subject: [PATCH] Look for currently-running python's pip first This improves pip detection on hosts where "pip" exists and refers to a different Python version from the Python under which Salt is running. It does so by getting the major and minor version from sys.version_info and looking for pipX.Y before checking the rest of the potential names for pip. --- salt/modules/pip.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/salt/modules/pip.py b/salt/modules/pip.py index f71bf36948..7ae1810498 100644 --- a/salt/modules/pip.py +++ b/salt/modules/pip.py @@ -81,6 +81,7 @@ import os import re import shutil import logging +import sys # Import salt libs import salt.utils @@ -118,7 +119,10 @@ def _get_pip_bin(bin_env): executable itself, or from searching conventional filesystem locations ''' if not bin_env: - which_result = __salt__['cmd.which_bin'](['pip', 'pip2', 'pip3', 'pip-python']) + which_result = __salt__['cmd.which_bin']( + ['pip{0}.{1}'.format(*sys.version_info[:2]), + 'pip', 'pip2', 'pip3', 'pip-python'] + ) if which_result is None: raise CommandNotFoundError('Could not find a `pip` binary') if salt.utils.is_windows():