Просмотр исходного кода

Merge pull request #953 from pyenv/source-shim

Workaround for scripts in `$PATH` which needs to be source'd
pull/954/head
Yamashita, Yuu 9 лет назад
committed by GitHub
Родитель
Сommit
7dae19765c
6 измененных файлов: 48 добавлений и 3 удалений
  1. +5
    -3
      pyenv.d/rehash/conda.bash
  2. +3
    -0
      pyenv.d/rehash/conda.d/.gitignore
  3. +0
    -0
      pyenv.d/rehash/conda.d/default.list
  4. +31
    -0
      pyenv.d/rehash/source.bash
  5. +3
    -0
      pyenv.d/rehash/source.d/.gitignore
  6. +6
    -0
      pyenv.d/rehash/source.d/default.list

+ 5
- 3
pyenv.d/rehash/conda.bash Просмотреть файл

@ -12,12 +12,14 @@ conda_exists() {
}
shims=()
for shim in $(cat "${BASH_SOURCE%/*}/conda.txt"); do
if [ -n "${shim%%#*}" ]; then
shopt -s nullglob
for shim in $(cat "${BASH_SOURCE%/*}/conda.d/"*".list" | sort | uniq | sed -e 's/#.*$//' | sed -e '/^[[:space:]]*$/d'); do
if [ -n "${shim##*/}" ]; then
shims[${#shims[*]}]="${shim})return 0;;"
fi
done
eval "conda_shim(){ case \"\$1\" in ${shims[@]} *)return 1;;esac;}"
shopt -u nullglob
eval "conda_shim(){ case \"\${1##*/}\" in ${shims[@]} *)return 1;;esac;}"
# override `make_shims` to avoid conflict between pyenv-virtualenv's `envs.bash`
# https://github.com/pyenv/pyenv-virtualenv/blob/v20160716/etc/pyenv.d/rehash/envs.bash

+ 3
- 0
pyenv.d/rehash/conda.d/.gitignore Просмотреть файл

@ -0,0 +1,3 @@
*
!/.gitignore
!/default.list

pyenv.d/rehash/conda.txt → pyenv.d/rehash/conda.d/default.list Просмотреть файл


+ 31
- 0
pyenv.d/rehash/source.bash Просмотреть файл

@ -0,0 +1,31 @@
PROTOTYPE_SOURCE_SHIM_PATH="${SHIM_PATH}/.pyenv-source-shim"
shims=()
shopt -s nullglob
for shim in $(cat "${BASH_SOURCE%/*}/source.d/"*".list" | sort | uniq | sed -e 's/#.*$//' | sed -e '/^[[:space:]]*$/d'); do
if [ -n "${shim##*/}" ]; then
shims[${#shims[*]}]="${shim})return 0;;"
fi
done
shopt -u nullglob
eval "source_shim(){ case \"\${1##*/}\" in ${shims[@]} *)return 1;;esac;}"
cat > "${PROTOTYPE_SOURCE_SHIM_PATH}" <<SH
[ -n "\$PYENV_DEBUG" ] && set -x
export PYENV_ROOT="${PYENV_ROOT}"
program="\$("$(command -v pyenv)" which "\${BASH_SOURCE##*/}")"
if [ -e "\${program}" ]; then
. "\${program}" "\$@"
fi
SH
chmod +x "${PROTOTYPE_SOURCE_SHIM_PATH}"
shopt -s nullglob
for shim in "${SHIM_PATH}/"*; do
if source_shim "${shim}"; then
cp "${PROTOTYPE_SOURCE_SHIM_PATH}" "${shim}"
fi
done
shopt -u nullglob
rm -f "${PROTOTYPE_SOURCE_SHIM_PATH}"

+ 3
- 0
pyenv.d/rehash/source.d/.gitignore Просмотреть файл

@ -0,0 +1,3 @@
*
!/.gitignore
!/default.list

+ 6
- 0
pyenv.d/rehash/source.d/default.list Просмотреть файл

@ -0,0 +1,6 @@
# virtualenv
activate
activate.csh
activate.fish
# gettext (#688)
gettext.sh

Загрузка…
Отмена
Сохранить