pyenv/plugins/python-build/bin/pyenv-uninstall
Yamashita Yuu 6d307c6e11 import recent changes from ruby-build:
* verify checksum of downloaded archives.
* add PYTHON_BUILD_MIRROR_URL to use mirror site.
  But we don't have CloudFront setup as of now :-(
* rbenv 0.4.x style help messages
2013-01-31 13:27:39 +09:00

60 lines
1.2 KiB
Bash
Executable file

#!/usr/bin/env bash
#
# 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
exec pyenv versions --bare
fi
if [ -z "$PYENV_ROOT" ]; then
PYENV_ROOT="${HOME}/.pyenv"
fi
unset FORCE
if [ "$1" = "-f" ] || [ "$1" = "--force" ]; then
FORCE=true
shift
fi
DEFINITION="$1"
case "$DEFINITION" in
"" | -* )
# We can remove the sed fallback once pyenv 0.4.0 is widely available.
{ pyenv-help uninstall 2>/dev/null ||
sed -ne '/^#/!q;s/.\{1,2\}//;1,4d;p' < "$0"
} >&2
exit 1
;;
esac
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* ) ;;
* ) exit 1 ;;
esac
fi
if [ -d "$PREFIX" ]; then
rm -rf "$PREFIX"
pyenv rehash
fi