pyenv/pyenv.d/exec/pip-rehash.bash
Christian Fredrik Johnsen 372ffab430 fix: look for -m followed by pip instead of looking for python -m pip
It isn't necessarily the case that the command will be python, it can be
both python3, python2, python3.12, etc.
2024-12-26 21:02:03 +01:00

22 lines
682 B
Bash

PYENV_PIP_REHASH_ROOT="${BASH_SOURCE[0]%/*}/pip-rehash"
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
for (( i=1; i<$#; i++ )); do
next=$((i+1))
if [[ ${!i} == "-m" && ${!next} == "pip" ]]; then
PYENV_REHASH_COMMAND="pip"
break
fi
done
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