-
Notifications
You must be signed in to change notification settings - Fork 542
Use pip from specified python cmd #2115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2731,23 +2731,21 @@ __install_salt_from_repo() { | |
| echodebug "__install_salt_from_repo py_exe=$_py_exe" | ||
|
|
||
| _py_version=$(${_py_exe} -c "import sys; print('{0}.{1}'.format(*sys.version_info))") | ||
| _pip_cmd="pip${_py_version}" | ||
| if ! __check_command_exists "${_pip_cmd}"; then | ||
| echodebug "The pip binary '${_pip_cmd}' was not found in PATH" | ||
| _pip_cmd="pip$(echo "${_py_version}" | cut -c -1)" | ||
| _pip_cmd="${_py_exe} -m pip" | ||
| _pip_version="$(${_pip_cmd} --version)" | ||
| if [ -z "${_pip_version}" ]; then | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Relying on string length of the output can occasionally be brittle depending on the shell environment or if python outputs unexpected warnings to stdout. A more robust and idiomatic way to check if the module works is to evaluate the exit code of the command directly. if ! ${_pip_cmd} --version >/dev/null 2>&1; then |
||
| echodebug "Pip is not installed for Python '${_py_exe}' (version ${_py_version})" | ||
| _pip_cmd="pip${_py_version}" | ||
| if ! __check_command_exists "${_pip_cmd}"; then | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Blocker:
Since we've already successfully verified the command works if it hits the fallback logic, we should bypass Suggested Change: _pip_cmd="${_py_exe} -m pip"
if ${_pip_cmd} --version >/dev/null 2>&1; then
_pip_version="$( ${_pip_cmd} --version 2>/dev/null )"
else
echodebug "Pip is not installed for Python '${_py_exe}' (version ${_py_version})"
# Fallback to looking for standard standalone binaries
_pip_cmd="pip${_py_version}"
if ! __check_command_exists "${_pip_cmd}"; then
echodebug "The pip binary '${_pip_cmd}' was not found in PATH"
echoerror "Unable to find a pip binary"
return 1
fi
_pip_version="$( ${_pip_cmd} --version 2>/dev/null )"
fi |
||
| echodebug "The pip binary '${_pip_cmd}' was not found in PATH" | ||
| _pip_cmd="pip" | ||
| if ! __check_command_exists "${_pip_cmd}"; then | ||
| echoerror "Unable to find a pip binary" | ||
| return 1 | ||
| fi | ||
| echoerror "Unable to find a pip binary" | ||
| return 1 | ||
| fi | ||
| fi | ||
|
|
||
| __check_pip_allowed | ||
|
|
||
| echodebug "Installed pip version: $(${_pip_cmd} --version)" | ||
| echodebug "Installed pip version: $_pip_version" | ||
|
|
||
| _setuptools_dep="setuptools>=${_MINIMUM_SETUPTOOLS_VERSION},<${_MAXIMUM_SETUPTOOLS_VERSION}" | ||
| if [ "$_PY_MAJOR_VERSION" -ne 3 ]; then | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If pip is not installed, running ${_pip_cmd} --version will dump a No module named pip traceback or command error to stderr. We should silence stderr here so the terminal output stays clean for the user during the check.
_pip_version="$( ${_pip_cmd} --version 2>/dev/null )"