From aae3bf2786619a400465af07b4e32db9b270f14f Mon Sep 17 00:00:00 2001 From: "Yamashita, Yuu" Date: Fri, 4 Dec 2015 00:27:09 +0000 Subject: [PATCH] Add workaround for rywyo/anyenv --- bin/pyenv-sh-deactivate | 8 ++++++-- bin/pyenv-virtualenv | 8 ++++---- bin/pyenv-virtualenv-delete | 6 +++++- 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/bin/pyenv-sh-deactivate b/bin/pyenv-sh-deactivate index 7638de9..0be5bc3 100755 --- a/bin/pyenv-sh-deactivate +++ b/bin/pyenv-sh-deactivate @@ -9,6 +9,10 @@ set -e [ -n "$PYENV_DEBUG" ] && set -x +if [ -z "${PYENV_ROOT}" ]; then + PYENV_ROOT="$(pyenv-root)" +fi + unset FORCE unset QUIET unset VERBOSE @@ -48,8 +52,8 @@ fi shell="$(basename "${PYENV_SHELL:-$SHELL}")" prefix="${VIRTUAL_ENV}" -if [[ "${prefix}" != "${prefix%/envs/*}" ]]; then - venv="$(basename "${prefix%/envs/*}")/envs/${prefix##*/}" +if [[ "${prefix%/*/envs/*}" == "${PYENV_ROOT}/versions" ]]; then + venv="${prefix#${PYENV_ROOT}/versions/}" else venv="${prefix##*/}" fi diff --git a/bin/pyenv-virtualenv b/bin/pyenv-virtualenv index 2af1567..5b52662 100755 --- a/bin/pyenv-virtualenv +++ b/bin/pyenv-virtualenv @@ -11,13 +11,13 @@ PYENV_VIRTUALENV_VERSION="20151103" +set -e +[ -n "$PYENV_DEBUG" ] && set -x + if [ -z "${PYENV_ROOT}" ]; then PYENV_ROOT="$(pyenv-root)" fi -set -e -[ -n "$PYENV_DEBUG" ] && set -x - # Provide pyenv completions if [ "$1" = "--complete" ]; then exec pyenv-versions --bare @@ -347,7 +347,7 @@ else fi VIRTUALENV_PATH="${PYENV_ROOT}/versions/${VIRTUALENV_NAME}" -if [[ "${VIRTUALENV_PATH}" != "${VIRTUALENV_PATH%/envs/*}" ]]; then +if [[ "${VIRTUALENV_PATH/*/envs/*}" != "${PYENV_ROOT}/versions" ]]; then COMPAT_VIRTUALENV_PATH="${PYENV_ROOT}/versions/${VIRTUALENV_NAME##*/}" fi diff --git a/bin/pyenv-virtualenv-delete b/bin/pyenv-virtualenv-delete index 90900f5..99d23d4 100755 --- a/bin/pyenv-virtualenv-delete +++ b/bin/pyenv-virtualenv-delete @@ -13,6 +13,10 @@ set -e [ -n "$PYENV_DEBUG" ] && set -x +if [ -z "${PYENV_ROOT}" ]; then + PYENV_ROOT="$(pyenv-root)" +fi + # Provide pyenv completions if [ "$1" = "--complete" ]; then exec pyenv virtualenvs --bare @@ -63,7 +67,7 @@ if [[ "${DEFINITION}" != "${DEFINITION%/envs/*}" ]]; then else if [ -L "${COMPAT_PREFIX}" ]; then PREFIX="$(resolve_link "${COMPAT_PREFIX}" 2>/dev/null || true)" - if [[ "${PREFIX}" == "${PREFIX%/envs/*}" ]]; then + if [[ "${PREFIX%/*/envs/*}" != "${PYENV_ROOT}/versions" ]]; then echo "pyenv-virtualenv: \`${COMPAT_PREFIX}' is a symlink for unknown location." 1>&2 exit 1 fi