Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2021
332
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 3.73 KB | None | 0 0
  1. export CONDA_EXE='/opt/conda/bin/conda'
  2. export _CE_M=''
  3. export _CE_CONDA=''
  4. export CONDA_PYTHON_EXE='/opt/conda/bin/python'
  5.  
  6. # Copyright (C) 2012 Anaconda, Inc
  7. # SPDX-License-Identifier: BSD-3-Clause
  8.  
  9. __add_sys_prefix_to_path() {
  10.     # In dev-mode CONDA_EXE is python.exe and on Windows
  11.     # it is in a different relative location to condabin.
  12.     if [ -n "${_CE_CONDA}" ] && [ -n "${WINDIR+x}" ]; then
  13.         SYSP=$(\dirname "${CONDA_EXE}")
  14.     else
  15.         SYSP=$(\dirname "${CONDA_EXE}")
  16.         SYSP=$(\dirname "${SYSP}")
  17.     fi
  18.  
  19.     if [ -n "${WINDIR+x}" ]; then
  20.         PATH="${SYSP}/bin:${PATH}"
  21.         PATH="${SYSP}/Scripts:${PATH}"
  22.         PATH="${SYSP}/Library/bin:${PATH}"
  23.         PATH="${SYSP}/Library/usr/bin:${PATH}"
  24.         PATH="${SYSP}/Library/mingw-w64/bin:${PATH}"
  25.         PATH="${SYSP}:${PATH}"
  26.     else
  27.         PATH="${SYSP}/bin:${PATH}"
  28.     fi
  29.     \export PATH
  30. }
  31.  
  32. __conda_hashr() {
  33.     if [ -n "${ZSH_VERSION:+x}" ]; then
  34.         \rehash
  35.     elif [ -n "${POSH_VERSION:+x}" ]; then
  36.         :  # pass
  37.     else
  38.         \hash -r
  39.     fi
  40. }
  41.  
  42. __conda_activate() {
  43.     if [ -n "${CONDA_PS1_BACKUP:+x}" ]; then
  44.         # Handle transition from shell activated with conda <= 4.3 to a subsequent activation
  45.         # after conda updated to >= 4.4. See issue #6173.
  46.         PS1="$CONDA_PS1_BACKUP"
  47.         \unset CONDA_PS1_BACKUP
  48.     fi
  49.  
  50.     \local cmd="$1"
  51.     shift
  52.     \local ask_conda
  53.     CONDA_INTERNAL_OLDPATH="${PATH}"
  54.     __add_sys_prefix_to_path
  55.     ask_conda="$(PS1="$PS1" "$CONDA_EXE" $_CE_M $_CE_CONDA shell.posix "$cmd" "$@")" || \return $?
  56.     rc=$?
  57.     PATH="${CONDA_INTERNAL_OLDPATH}"
  58.     \eval "$ask_conda"
  59.     if [ $rc != 0 ]; then
  60.         \export PATH
  61.     fi
  62.     __conda_hashr
  63. }
  64.  
  65. __conda_reactivate() {
  66.     \local ask_conda
  67.     CONDA_INTERNAL_OLDPATH="${PATH}"
  68.     __add_sys_prefix_to_path
  69.     ask_conda="$(PS1="$PS1" "$CONDA_EXE" $_CE_M $_CE_CONDA shell.posix reactivate)" || \return $?
  70.     PATH="${CONDA_INTERNAL_OLDPATH}"
  71.     \eval "$ask_conda"
  72.     __conda_hashr
  73. }
  74.  
  75. conda() {
  76.     if [ "$#" -lt 1 ]; then
  77.         "$CONDA_EXE" $_CE_M $_CE_CONDA
  78.     else
  79.         \local cmd="$1"
  80.         shift
  81.         case "$cmd" in
  82.             activate|deactivate)
  83.                 __conda_activate "$cmd" "$@"
  84.                 ;;
  85.             install|update|upgrade|remove|uninstall)
  86.                 CONDA_INTERNAL_OLDPATH="${PATH}"
  87.                 __add_sys_prefix_to_path
  88.                 "$CONDA_EXE" $_CE_M $_CE_CONDA "$cmd" "$@"
  89.                 \local t1=$?
  90.                 PATH="${CONDA_INTERNAL_OLDPATH}"
  91.                 if [ $t1 = 0 ]; then
  92.                     __conda_reactivate
  93.                 else
  94.                     return $t1
  95.                 fi
  96.                 ;;
  97.             *)
  98.                 CONDA_INTERNAL_OLDPATH="${PATH}"
  99.                 __add_sys_prefix_to_path
  100.                 "$CONDA_EXE" $_CE_M $_CE_CONDA "$cmd" "$@"
  101.                 \local t1=$?
  102.                 PATH="${CONDA_INTERNAL_OLDPATH}"
  103.                 return $t1
  104.                 ;;
  105.         esac
  106.     fi
  107. }
  108.  
  109. if [ -z "${CONDA_SHLVL+x}" ]; then
  110.     \export CONDA_SHLVL=0
  111.     # In dev-mode CONDA_EXE is python.exe and on Windows
  112.     # it is in a different relative location to condabin.
  113.     if [ -n "${_CE_CONDA+x}" ] && [ -n "${WINDIR+x}" ]; then
  114.         PATH="$(\dirname "$CONDA_EXE")/condabin${PATH:+":${PATH}"}"
  115.    else
  116.        PATH="$(\dirname "$(\dirname "$CONDA_EXE")")/condabin${PATH:+":${PATH}"}"
  117.     fi
  118.     \export PATH
  119.  
  120.     # We're not allowing PS1 to be unbound. It must at least be set.
  121.     # However, we're not exporting it, which can cause problems when starting a second shell
  122.     # via a first shell (i.e. starting zsh from bash).
  123.     if [ -z "${PS1+x}" ]; then
  124.         PS1=
  125.     fi
  126. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement