#!/usr/bin/env bash # # Summary: Deactivate virtual environment # # Usage: pyenv deactivate # # Deactivate a Python virtual environment. set -e [ -n "$PYENV_DEBUG" ] && set -x unset NOERROR unset VERBOSE while [ $# -gt 0 ]; do case "$1" in "--no-error" ) NOERROR=1 ;; "--verbose" ) VERBOSE=1 ;; * ) break ;; esac shift 1 done shell="$(basename "${PYENV_SHELL:-$SHELL}")" case "$shell" in fish ) echo "if functions -q deactivate;" ;; * ) echo "if declare -f deactivate 1>/dev/null 2>&1; then" ;; esac prefix="${PYENV_ACTIVATE:-${VIRTUAL_ENV}}" if [ -n "$VERBOSE" ]; then echo " echo \"pyenv-virtualenv: deactivate ${prefix##*/}\" 1>&2;" fi if [ -z "${PYENV_VIRTUALENV_INIT}" ]; then # Backward compatibility issue # https://github.com/yyuu/pyenv-virtualenv/issues/26 echo " pyenv shell --unset;" fi case "$shell" in fish ) cat <&2;" fi echo " false;" case "$shell" in fish ) echo "end;" ;; * ) echo "fi;" ;; esac