1 Commits

Author SHA1 Message Date
Yamashita Yuu
56c232610a Check the usage of virtualenv(s) before the uninstallation of versions 2014-04-29 00:51:57 +09:00
9 changed files with 40 additions and 17 deletions

View File

@@ -131,11 +131,6 @@ You can set certain environment variables to control the pyenv-virtualenv.
## Version History
#### 20140602
* Use new style GH raw url to avoid redirects (raw.github.com -> raw.githubusercontent.com)
* Repaired virtualenv activation and deactivation for the fish shell (#23)
#### 20140421
* Display error if `pyenv activate` was invoked as a command

View File

@@ -41,7 +41,7 @@ fi
pyenv-virtualenv-prefix "${versions}" 1>/dev/null
echo "pyenv shell \"${versions}\";"
echo "pyenv shell \"${versions}\""
case "$shell" in
fish ) echo ". \"$(pyenv-prefix "${versions}")/bin/activate.fish\"" ;;
* ) echo "source \"$(pyenv-prefix "${versions}")/bin/activate\"" ;;

View File

@@ -11,7 +11,7 @@ set -e
shell="$(basename "${PYENV_SHELL:-$SHELL}")"
case "$shell" in
fish ) echo "functions -q deactivate; and deactivate;";;
* ) echo "declare -f deactivate 1>/dev/null 2>&1 && deactivate;";;
fish ) echo "functions -q deactivate; and deactivate";;
* ) echo "declare -f deactivate 1>/dev/null 2>&1 && deactivate";;
esac
echo "pyenv shell --unset"

View File

@@ -11,7 +11,7 @@
# -f/--force Install even if the version appears to be installed already
#
PYENV_VIRTUALENV_VERSION="20140602"
PYENV_VIRTUALENV_VERSION="20140421"
set -e
[ -n "$PYENV_DEBUG" ] && set -x
@@ -181,9 +181,9 @@ install_pip() {
else
[ -n "${GET_PIP_URL}" ] || {
if [ -n "${PIP_VERSION}" ]; then
GET_PIP_URL="https://raw.githubusercontent.com/pypa/pip/${PIP_VERSION}/contrib/get-pip.py"
GET_PIP_URL="https://raw.github.com/pypa/pip/${PIP_VERSION}/contrib/get-pip.py"
else
GET_PIP_URL="https://raw.githubusercontent.com/pypa/pip/master/contrib/get-pip.py"
GET_PIP_URL="https://raw.github.com/pypa/pip/master/contrib/get-pip.py"
fi
}
if [ -n "$VERBOSE" ]; then

View File

@@ -0,0 +1,25 @@
VERSION_NAME="${DEFINITION##*/}"
PREFIX="${PYENV_ROOT}/versions/${VERSION_NAME}"
if ! pyenv-virtualenv-prefix "${VERSION_NAME}" 1>/dev/null 2>&1; then
OLDIFS="$IFS"
IFS=$'\n' virtualenvs=($(pyenv-virtualenvs --bare))
IFS="$OLDIFS"
declare -a dependencies
for venv in "${virtualenvs[@]}"; do
venv_prefix="$(pyenv-virtualenv-prefix "${venv}" 2>/dev/null || true)"
if [ -d "${venv_prefix}" ] && [ "${PREFIX}" = "${venv_prefix}" ]; then
dependencies[${#dependencies[*]}]="${venv}"
fi
done
if [ -z "$FORCE" ] && [ -n "$dependencies" ]; then
echo "pyenv: ${#dependencies[@]} virtualenv(s) is depending on $PREFIX." >&2
read -p "continue with uninstallation? (y/N) "
case "$REPLY" in
y* | Y* ) ;;
* ) exit 1 ;;
esac
fi
fi

View File

@@ -12,7 +12,10 @@ if [ -z "${PREFIX}" ]; then
fi
BIN_PATH="${PREFIX}/bin"
ETC_PATH="${PREFIX}/etc/pyenv.d"
mkdir -p "$BIN_PATH"
mkdir -p "$ETC_PATH"
install -p bin/* "$BIN_PATH"
cp -RPp etc/pyenv.d/* "$ETC_PATH"

View File

@@ -19,7 +19,7 @@ setup() {
assert_success
assert_output <<EOS
pyenv shell "venv";
pyenv shell "venv"
source "${PYENV_ROOT}/versions/venv/bin/activate"
EOS
}
@@ -37,7 +37,7 @@ EOS
assert_success
assert_output <<EOS
pyenv shell "venv";
pyenv shell "venv"
. "${PYENV_ROOT}/versions/venv/bin/activate.fish"
EOS
}
@@ -53,7 +53,7 @@ EOS
assert_success
assert_output <<EOS
pyenv shell "venv27";
pyenv shell "venv27"
source "${PYENV_ROOT}/versions/venv27/bin/activate"
EOS
}

View File

@@ -11,7 +11,7 @@ setup() {
assert_success
assert_output <<EOS
declare -f deactivate 1>/dev/null 2>&1 && deactivate;
declare -f deactivate 1>/dev/null 2>&1 && deactivate
pyenv shell --unset
EOS
}
@@ -21,7 +21,7 @@ EOS
assert_success
assert_output <<EOS
functions -q deactivate; and deactivate;
functions -q deactivate; and deactivate
pyenv shell --unset
EOS
}

View File

@@ -4,7 +4,7 @@ load test_helper
setup() {
export PYENV_ROOT="${TMP}/pyenv"
export PYENV_VIRTUALENV_VERSION="20140602"
export PYENV_VIRTUALENV_VERSION="20140421"
}
@test "display virtualenv version" {