From 481198d25560086ef426f69fc92fcda0c3daef1d Mon Sep 17 00:00:00 2001 From: Daniel Hahler Date: Wed, 29 Apr 2015 13:53:46 +0200 Subject: [PATCH] pip-rehash: handle versions in commands, like "pip2" and "pip3.4" Fixes https://github.com/yyuu/pyenv/issues/367 --- pyenv.d/exec/pip-rehash.bash | 14 +++++++++++--- pyenv.d/exec/pip-rehash/easy_install | 2 +- pyenv.d/exec/pip-rehash/pip | 2 +- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/pyenv.d/exec/pip-rehash.bash b/pyenv.d/exec/pip-rehash.bash index e231e47a..7080f45d 100644 --- a/pyenv.d/exec/pip-rehash.bash +++ b/pyenv.d/exec/pip-rehash.bash @@ -1,5 +1,13 @@ PYENV_PIP_REHASH_ROOT="${BASH_SOURCE[0]%/*}/pip-rehash" -if [ -x "${PYENV_PIP_REHASH_ROOT}/${PYENV_COMMAND##*/}" ]; then - PYENV_COMMAND_PATH="${PYENV_PIP_REHASH_ROOT}/${PYENV_COMMAND##*/}" - PYENV_BIN_PATH="${PYENV_PIP_REHASH_ROOT}" +PYENV_REHASH_COMMAND="${PYENV_COMMAND##*/}" + +# Remove any version information, from e.g. "pip2" or "pip3.4". +if [[ $PYENV_REHASH_COMMAND =~ ^(pip|easy_install)[23](\.\d)?$ ]]; then + PYENV_REHASH_COMMAND="${BASH_REMATCH[1]}" +fi + +if [ -x "${PYENV_PIP_REHASH_ROOT}/${PYENV_REHASH_COMMAND}" ]; then + PYENV_COMMAND_PATH="${PYENV_PIP_REHASH_ROOT}/${PYENV_REHASH_COMMAND##*/}" + PYENV_BIN_PATH="${PYENV_PIP_REHASH_ROOT}" + export PYENV_REHASH_REAL_COMMAND="${PYENV_COMMAND##*/}" fi diff --git a/pyenv.d/exec/pip-rehash/easy_install b/pyenv.d/exec/pip-rehash/easy_install index d0b080b2..cf559dcb 100755 --- a/pyenv.d/exec/pip-rehash/easy_install +++ b/pyenv.d/exec/pip-rehash/easy_install @@ -11,7 +11,7 @@ _PATH="${_PATH#:}" _PATH="${_PATH%:}" PATH="${_PATH}" -PYENV_COMMAND_PATH="$(pyenv-which "$(basename "$0")")" +PYENV_COMMAND_PATH="$(pyenv-which "${PYENV_REHASH_REAL_COMMAND}")" PYENV_BIN_PATH="${PYENV_COMMAND_PATH%/*}" export PATH="${PYENV_BIN_PATH}:${PATH}" diff --git a/pyenv.d/exec/pip-rehash/pip b/pyenv.d/exec/pip-rehash/pip index f4e7ce7d..8f663726 100755 --- a/pyenv.d/exec/pip-rehash/pip +++ b/pyenv.d/exec/pip-rehash/pip @@ -11,7 +11,7 @@ _PATH="${_PATH#:}" _PATH="${_PATH%:}" PATH="${_PATH}" -PYENV_COMMAND_PATH="$(pyenv-which "$(basename "$0")")" +PYENV_COMMAND_PATH="$(pyenv-which "${PYENV_REHASH_REAL_COMMAND}")" PYENV_BIN_PATH="${PYENV_COMMAND_PATH%/*}" export PATH="${PYENV_BIN_PATH}:${PATH}"