From a73817eeccfa0236c4662778fb14c39a0047ab2e Mon Sep 17 00:00:00 2001 From: "Yamashita, Yuu" Date: Thu, 12 Nov 2015 00:28:44 +0000 Subject: [PATCH] Use canonical name for `VIRTUAL_ENV` as a workaround for IPython (fixes #113) --- bin/pyenv-sh-activate | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/bin/pyenv-sh-activate b/bin/pyenv-sh-activate index 592a002..d80f742 100755 --- a/bin/pyenv-sh-activate +++ b/bin/pyenv-sh-activate @@ -14,6 +14,10 @@ set -e [ -n "$PYENV_DEBUG" ] && set -x +resolve_link() { + $(type -p greadlink readlink | head -1) "$1" +} + unset FORCE unset QUIET unset VERBOSE @@ -86,6 +90,10 @@ done shell="${PYENV_SHELL:-${SHELL##*/}}" prefix="$(pyenv-prefix "${venv}")" +if [ -L "${prefix}" ]; then + prefix="$(resolve_link "${prefix}" 2>/dev/null)" +fi + if [[ "${VIRTUAL_ENV}" == "${prefix}" ]]; then if [ -z "${QUIET}" ]; then echo "pyenv-virtualenv: version \`${venv}' is already activated" 1>&2