mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-17 07:53:42 -05:00
activate/deactivate anaconda/miniconda envs
This commit is contained in:
@@ -28,17 +28,43 @@ while [ $# -gt 0 ]; do
|
||||
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}}"
|
||||
|
||||
unset conda_env
|
||||
|
||||
if [ -f "${prefix}/bin/conda" ]; then
|
||||
if [[ "${prefix}" != "${prefix%/envs/*}" ]]; then
|
||||
case "$shell" in
|
||||
bash )
|
||||
conda_env="${prefix##*/envs/}"
|
||||
;;
|
||||
zsh )
|
||||
conda_env="${prefix##*/envs/}"
|
||||
;;
|
||||
* )
|
||||
echo "false"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
else
|
||||
echo "false"
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -n "${conda_env}" ]; then
|
||||
echo "if [ -f \"${prefix%/envs/*}/bin/deactivate\" ]; then"
|
||||
else
|
||||
case "$shell" in
|
||||
fish )
|
||||
echo "if functions -q deactivate;"
|
||||
;;
|
||||
* )
|
||||
echo "if declare -f deactivate 1>/dev/null 2>&1; then"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ -n "$VERBOSE" ]; then
|
||||
echo " echo \"pyenv-virtualenv: deactivate ${prefix##*/}\" 1>&2;"
|
||||
fi
|
||||
@@ -57,24 +83,33 @@ if [ -n "${PYENV_ACTIVATE_SHELL}" ]; then
|
||||
esac
|
||||
fi
|
||||
|
||||
case "$shell" in
|
||||
fish )
|
||||
if [ -n "${conda_env}" ]; then
|
||||
cat <<EOS
|
||||
export PYENV_DEACTIVATE="$prefix";
|
||||
unset PYENV_ACTIVATE;
|
||||
. "${prefix%/envs/*}/bin/deactivate" "${prefix##*/envs/}";
|
||||
else
|
||||
EOS
|
||||
else
|
||||
case "$shell" in
|
||||
fish )
|
||||
cat <<EOS
|
||||
setenv PYENV_DEACTIVATE "$prefix";
|
||||
set -e PYENV_ACTIVATE;
|
||||
deactivate;
|
||||
else;
|
||||
EOS
|
||||
;;
|
||||
* )
|
||||
cat <<EOS
|
||||
;;
|
||||
* )
|
||||
cat <<EOS
|
||||
export PYENV_DEACTIVATE="$prefix";
|
||||
unset PYENV_ACTIVATE;
|
||||
deactivate;
|
||||
else
|
||||
EOS
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [ -z "$NOERROR" ]; then
|
||||
echo " echo \"pyenv-virtualenv: no virtualenv has been activated.\" 1>&2;"
|
||||
|
||||
Reference in New Issue
Block a user