mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-21 20:47:00 -05:00
Merge pull request #953 from pyenv/source-shim
Workaround for scripts in `$PATH` which needs to be source'd
This commit is contained in:
commit
7dae19765c
6 changed files with 48 additions and 3 deletions
|
@ -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
3
pyenv.d/rehash/conda.d/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
*
|
||||
!/.gitignore
|
||||
!/default.list
|
31
pyenv.d/rehash/source.bash
Normal file
31
pyenv.d/rehash/source.bash
Normal 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
3
pyenv.d/rehash/source.d/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
*
|
||||
!/.gitignore
|
||||
!/default.list
|
6
pyenv.d/rehash/source.d/default.list
Normal file
6
pyenv.d/rehash/source.d/default.list
Normal file
|
@ -0,0 +1,6 @@
|
|||
# virtualenv
|
||||
activate
|
||||
activate.csh
|
||||
activate.fish
|
||||
# gettext (#688)
|
||||
gettext.sh
|
Loading…
Reference in a new issue