mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-21 20:47:00 -05:00
83e5459cfb
All scripts in libexec/ (excluding pyenv) are called through pyenv, therefore the shebang lines are not necessary. On some systems this provides a measurable increase in performance of the shell prompt. Related to pyenv/pyenv-virtualenv#259
84 lines
1.6 KiB
Text
Executable file
84 lines
1.6 KiB
Text
Executable file
# Summary: Uninstall a specific Python version
|
|
#
|
|
# Usage: pyenv uninstall [-f|--force] <version>
|
|
#
|
|
# -f Attempt to remove the specified version without prompting
|
|
# for confirmation. If the version does not exist, do not
|
|
# display an error message.
|
|
#
|
|
# See `pyenv versions` for a complete list of installed versions.
|
|
#
|
|
set -e
|
|
|
|
# Provide pyenv completions
|
|
if [ "$1" = "--complete" ]; then
|
|
echo --force
|
|
exec pyenv versions --bare
|
|
fi
|
|
|
|
usage() {
|
|
pyenv-help uninstall 2>/dev/null
|
|
[ -z "$1" ] || exit "$1"
|
|
}
|
|
|
|
if [ "$1" = "-h" ] || [ "$1" = "--help" ]; then
|
|
usage 0
|
|
fi
|
|
|
|
unset FORCE
|
|
if [ "$1" = "-f" ] || [ "$1" = "--force" ]; then
|
|
FORCE=true
|
|
shift
|
|
fi
|
|
|
|
[ "$#" -eq 1 ] || usage 1 >&2
|
|
|
|
DEFINITION="$1"
|
|
case "$DEFINITION" in
|
|
"" | -* )
|
|
usage 1 >&2
|
|
;;
|
|
esac
|
|
|
|
declare -a before_hooks after_hooks
|
|
|
|
before_uninstall() {
|
|
local hook="$1"
|
|
before_hooks["${#before_hooks[@]}"]="$hook"
|
|
}
|
|
|
|
after_uninstall() {
|
|
local hook="$1"
|
|
after_hooks["${#after_hooks[@]}"]="$hook"
|
|
}
|
|
|
|
OLDIFS="$IFS"
|
|
IFS=$'\n' scripts=(`pyenv-hooks uninstall`)
|
|
IFS="$OLDIFS"
|
|
for script in "${scripts[@]}"; do source "$script"; done
|
|
|
|
|
|
VERSION_NAME="${DEFINITION##*/}"
|
|
PREFIX="${PYENV_ROOT}/versions/${VERSION_NAME}"
|
|
|
|
if [ -z "$FORCE" ]; then
|
|
if [ ! -d "$PREFIX" ]; then
|
|
echo "pyenv: version \`$VERSION_NAME' not installed" >&2
|
|
exit 1
|
|
fi
|
|
|
|
read -p "pyenv: remove $PREFIX? "
|
|
case "$REPLY" in
|
|
y | Y | yes | YES ) ;;
|
|
* ) exit 1 ;;
|
|
esac
|
|
fi
|
|
|
|
for hook in "${before_hooks[@]}"; do eval "$hook"; done
|
|
|
|
if [ -d "$PREFIX" ]; then
|
|
rm -rf "$PREFIX"
|
|
pyenv-rehash
|
|
fi
|
|
|
|
for hook in "${after_hooks[@]}"; do eval "$hook"; done
|