From d6bc5837533d300a1ee83ef4ca4cdda0dec62f2f Mon Sep 17 00:00:00 2001 From: "Yamashita, Yuu" Date: Tue, 24 May 2016 00:39:40 +0000 Subject: [PATCH 1/2] Source conda package activate/deactivat scripts if exist (fixes #173) --- bin/pyenv-sh-activate | 16 ++++++++++++++++ bin/pyenv-sh-deactivate | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/bin/pyenv-sh-activate b/bin/pyenv-sh-activate index 53452d4..3a8d96c 100755 --- a/bin/pyenv-sh-activate +++ b/bin/pyenv-sh-activate @@ -231,3 +231,19 @@ EOS ;; esac fi + +# conda package anaconda/miniconda scripts (#173) +if [ -x "${prefix}/bin/conda" ]; then + shopt -s nullglob + case "${shell}" in + fish ) + : # conda doesn't support fish + ;; + * ) + for script in "${prefix}/etc/conda/activate.d"/*.sh; do + echo ". \"${script}\";" + done + ;; + esac + shopt -u nullglob +fi diff --git a/bin/pyenv-sh-deactivate b/bin/pyenv-sh-deactivate index 134a8f2..c590333 100755 --- a/bin/pyenv-sh-deactivate +++ b/bin/pyenv-sh-deactivate @@ -58,6 +58,22 @@ if [ -n "$PYENV_VIRTUALENV_VERBOSE_ACTIVATE" ]; then echo "pyenv-virtualenv: deactivate ${venv}" 1>&2 fi +# conda package anaconda/miniconda scripts (#173) +if [ -x "${prefix}/bin/conda" ]; then + shopt -s nullglob + case "${shell}" in + fish ) + : # conda doesn't support fish + ;; + * ) + for script in "${prefix}/etc/conda/deactivate.d"/*.sh; do + echo ". \"${script}\";" + done + ;; + esac + shopt -u nullglob +fi + if [ -n "${PYENV_ACTIVATE_SHELL}" ]; then # shell version set in pyenv-sh-activate should be unset # https://github.com/yyuu/pyenv-virtualenv/issues/61 From d9391b4fb99cffe9dd860f1a63bc6ca1f24a59b8 Mon Sep 17 00:00:00 2001 From: "Yamashita, Yuu" Date: Wed, 25 May 2016 00:53:44 +0000 Subject: [PATCH 2/2] Add tests for conda's package activate/deactivate script --- test/conda-activate.bats | 2 ++ test/conda-deactivate.bats | 1 + test/test_helper.bash | 5 ++++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/test/conda-activate.bats b/test/conda-activate.bats index 92a500e..39d7301 100644 --- a/test/conda-activate.bats +++ b/test/conda-activate.bats @@ -126,6 +126,7 @@ export CONDA_DEFAULT_ENV="foo"; pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior. export _OLD_VIRTUAL_PS1="\${PS1}"; export PS1="(anaconda-2.3.0/envs/foo) \${PS1}"; +. "${PYENV_ROOT}/versions/anaconda-2.3.0/envs/foo/etc/conda/activate.d/activate.sh"; EOS unstub pyenv-version-name @@ -157,6 +158,7 @@ export CONDA_DEFAULT_ENV="bar"; pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior. export _OLD_VIRTUAL_PS1="\${PS1}"; export PS1="(miniconda-3.9.1/envs/bar) \${PS1}"; +. "${PYENV_ROOT}/versions/miniconda-3.9.1/envs/bar/etc/conda/activate.d/activate.sh"; EOS unstub pyenv-virtualenv-prefix diff --git a/test/conda-deactivate.bats b/test/conda-deactivate.bats index bf7442a..647b0c9 100644 --- a/test/conda-deactivate.bats +++ b/test/conda-deactivate.bats @@ -96,6 +96,7 @@ EOS assert_success assert_output <