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

This commit is contained in:
Christoph Paulik
2017-07-19 15:28:40 +02:00
parent e4d2c367cc
commit f64c8ed0dd
4 changed files with 9 additions and 0 deletions

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

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

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

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;