Merge pull request #953 from pyenv/source-shim

Workaround for scripts in `$PATH` which needs to be source'd
This commit is contained in:
Yamashita, Yuu 2017-07-21 09:58:37 +09:00 committed by GitHub
commit 7dae19765c
6 changed files with 48 additions and 3 deletions

View file

@ -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
pyenv.d/rehash/conda.d/.gitignore vendored Normal file
View file

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

View file

@ -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
pyenv.d/rehash/source.d/.gitignore vendored Normal file
View file

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

View file

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