From acce3744e7fe1125f658c22ef7fd4b8b91557cbd Mon Sep 17 00:00:00 2001 From: Yamashita Yuu Date: Mon, 1 Dec 2014 22:34:02 +0900 Subject: [PATCH] Add pip-rehash --- pyenv.d/exec/pip-rehash.bash | 5 +++++ pyenv.d/exec/pip-rehash/easy_install | 27 ++++++++++++++++++++++++++ pyenv.d/exec/pip-rehash/pip | 29 ++++++++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 pyenv.d/exec/pip-rehash.bash create mode 100755 pyenv.d/exec/pip-rehash/easy_install create mode 100755 pyenv.d/exec/pip-rehash/pip diff --git a/pyenv.d/exec/pip-rehash.bash b/pyenv.d/exec/pip-rehash.bash new file mode 100644 index 00000000..e231e47a --- /dev/null +++ b/pyenv.d/exec/pip-rehash.bash @@ -0,0 +1,5 @@ +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}" +fi diff --git a/pyenv.d/exec/pip-rehash/easy_install b/pyenv.d/exec/pip-rehash/easy_install new file mode 100755 index 00000000..d0b080b2 --- /dev/null +++ b/pyenv.d/exec/pip-rehash/easy_install @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +set -e +[ -n "$PYENV_DEBUG" ] && set -x + +# Remove pyenv-pip-rehash/libexec from PATH to avoid infinite loops in `pyenv-which` (yyuu/pyenv#146) +_PATH=":${PATH}:" +_HERE="$(dirname "${BASH_SOURCE[0]}")" # remove this from PATH +_PATH="${_PATH//:${_HERE}:/:}" +_PATH="${_PATH#:}" +_PATH="${_PATH%:}" +PATH="${_PATH}" + +PYENV_COMMAND_PATH="$(pyenv-which "$(basename "$0")")" +PYENV_BIN_PATH="${PYENV_COMMAND_PATH%/*}" + +export PATH="${PYENV_BIN_PATH}:${PATH}" + +STATUS=0 +"$PYENV_COMMAND_PATH" "$@" || STATUS="$?" + +# Run `pyenv-rehash` after a successful installation. +if [ "$STATUS" == "0" ]; then + pyenv-rehash +fi + +exit "$STATUS" diff --git a/pyenv.d/exec/pip-rehash/pip b/pyenv.d/exec/pip-rehash/pip new file mode 100755 index 00000000..f4e7ce7d --- /dev/null +++ b/pyenv.d/exec/pip-rehash/pip @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +set -e +[ -n "$PYENV_DEBUG" ] && set -x + +# Remove pyenv-pip-rehash/libexec from PATH to avoid infinite loops in `pyenv-which` (yyuu/pyenv#146) +_PATH=":${PATH}:" +_HERE="$(dirname "${BASH_SOURCE[0]}")" # remove this from PATH +_PATH="${_PATH//:${_HERE}:/:}" +_PATH="${_PATH#:}" +_PATH="${_PATH%:}" +PATH="${_PATH}" + +PYENV_COMMAND_PATH="$(pyenv-which "$(basename "$0")")" +PYENV_BIN_PATH="${PYENV_COMMAND_PATH%/*}" + +export PATH="${PYENV_BIN_PATH}:${PATH}" + +STATUS=0 +"$PYENV_COMMAND_PATH" "$@" || STATUS="$?" + +# Run `pyenv-rehash` after a successful installation. +if [ "$STATUS" == "0" ]; then + case "$1" in + "install" | "uninstall" ) pyenv-rehash;; + esac +fi + +exit "$STATUS"