Browse Source

Set CONDA_PREFIX to make is useable in conda activate/deactivate scripts.

pull/224/head
Christoph Paulik 7 years ago
parent
commit
f64c8ed0dd
4 changed files with 9 additions and 0 deletions
  1. +2
    -0
      bin/pyenv-sh-activate
  2. +1
    -0
      bin/pyenv-sh-deactivate
  3. +4
    -0
      test/conda-activate.bats
  4. +2
    -0
      test/conda-deactivate.bats

+ 2
- 0
bin/pyenv-sh-activate View File

@ -240,6 +240,8 @@ if [ -x "${prefix}/bin/conda" ]; then
: # conda doesn't support fish : # conda doesn't support fish
;; ;;
* ) * )
CONDA_PREFIX="$prefix"
echo "export CONDA_PREFIX=\"${CONDA_PREFIX}\";"
for script in "${prefix}/etc/conda/activate.d"/*.sh; do for script in "${prefix}/etc/conda/activate.d"/*.sh; do
echo ". \"${script}\";" echo ". \"${script}\";"
done done

+ 1
- 0
bin/pyenv-sh-deactivate View File

@ -69,6 +69,7 @@ if [ -x "${prefix}/bin/conda" ]; then
for script in "${prefix}/etc/conda/deactivate.d"/*.sh; do for script in "${prefix}/etc/conda/deactivate.d"/*.sh; do
echo ". \"${script}\";" echo ". \"${script}\";"
done done
echo "unset CONDA_PREFIX"
;; ;;
esac esac
shopt -u nullglob shopt -u nullglob

+ 4
- 0
test/conda-activate.bats View File

@ -39,6 +39,7 @@ export CONDA_DEFAULT_ENV="root";
pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior. 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 _OLD_VIRTUAL_PS1="\${PS1}";
export PS1="(anaconda-2.3.0) \${PS1}"; export PS1="(anaconda-2.3.0) \${PS1}";
export CONDA_PREFIX="${TMP}/pyenv/versions/anaconda-2.3.0";
EOS EOS
unstub pyenv-version-name unstub pyenv-version-name
@ -97,6 +98,7 @@ export CONDA_DEFAULT_ENV="root";
pyenv-virtualenv: prompt changing will be removed from future release. configure \`export PYENV_VIRTUALENV_DISABLE_PROMPT=1' to simulate the behavior. 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 _OLD_VIRTUAL_PS1="\${PS1}";
export PS1="(miniconda-3.9.1) \${PS1}"; export PS1="(miniconda-3.9.1) \${PS1}";
export CONDA_PREFIX="${TMP}/pyenv/versions/miniconda-3.9.1";
EOS EOS
unstub pyenv-virtualenv-prefix unstub pyenv-virtualenv-prefix
@ -126,6 +128,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. 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 _OLD_VIRTUAL_PS1="\${PS1}";
export PS1="(anaconda-2.3.0/envs/foo) \${PS1}"; export PS1="(anaconda-2.3.0/envs/foo) \${PS1}";
export CONDA_PREFIX="${TMP}/pyenv/versions/anaconda-2.3.0/envs/foo";
. "${PYENV_ROOT}/versions/anaconda-2.3.0/envs/foo/etc/conda/activate.d/activate.sh"; . "${PYENV_ROOT}/versions/anaconda-2.3.0/envs/foo/etc/conda/activate.d/activate.sh";
EOS EOS
@ -158,6 +161,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. 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 _OLD_VIRTUAL_PS1="\${PS1}";
export PS1="(miniconda-3.9.1/envs/bar) \${PS1}"; export PS1="(miniconda-3.9.1/envs/bar) \${PS1}";
export CONDA_PREFIX="${TMP}/pyenv/versions/miniconda-3.9.1/envs/bar";
. "${PYENV_ROOT}/versions/miniconda-3.9.1/envs/bar/etc/conda/activate.d/activate.sh"; . "${PYENV_ROOT}/versions/miniconda-3.9.1/envs/bar/etc/conda/activate.d/activate.sh";
EOS EOS

+ 2
- 0
test/conda-deactivate.bats View File

@ -30,6 +30,7 @@ setup() {
assert_success assert_success
assert_output <<EOS assert_output <<EOS
unset CONDA_PREFIX
unset PYENV_VIRTUAL_ENV; unset PYENV_VIRTUAL_ENV;
unset VIRTUAL_ENV; unset VIRTUAL_ENV;
unset CONDA_DEFAULT_ENV; unset CONDA_DEFAULT_ENV;
@ -97,6 +98,7 @@ EOS
assert_success assert_success
assert_output <<EOS assert_output <<EOS
. "${PYENV_ROOT}/versions/anaconda-2.3.0/envs/foo/etc/conda/deactivate.d/deactivate.sh"; . "${PYENV_ROOT}/versions/anaconda-2.3.0/envs/foo/etc/conda/deactivate.d/deactivate.sh";
unset CONDA_PREFIX
unset PYENV_VIRTUAL_ENV; unset PYENV_VIRTUAL_ENV;
unset VIRTUAL_ENV; unset VIRTUAL_ENV;
unset CONDA_DEFAULT_ENV; unset CONDA_DEFAULT_ENV;

Loading…
Cancel
Save