2016-05-10 04:21:53 +00:00
|
|
|
# Anaconda comes with binaries of system packages (e.g. `openssl`, `curl`).
|
|
|
|
# Creating shims for those binaries will prevent pyenv users to run those
|
|
|
|
# commands normally when not using Anaconda.
|
|
|
|
#
|
|
|
|
# This hooks is intended to skip creating shims for those executables.
|
|
|
|
|
|
|
|
conda_exists() {
|
|
|
|
shopt -s nullglob
|
|
|
|
local condas=($(echo "${PYENV_ROOT}/versions/"*"/bin/conda" "${PYENV_ROOT}/versions/"*"/envs/"*"/bin/conda"))
|
|
|
|
shopt -u nullglob
|
|
|
|
[ -n "${condas}" ]
|
|
|
|
}
|
|
|
|
|
2016-08-15 05:30:18 +00:00
|
|
|
shims=()
|
|
|
|
for shim in $(cat "${BASH_SOURCE%/*}/conda.txt"); do
|
|
|
|
if [ -n "${shim%%#*}" ]; then
|
|
|
|
shims[${#shims[*]}]="${shim})return 0;;"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
eval "conda_shim(){ case \"\$1\" in ${shims[@]} *)return 1;;esac;}"
|
2016-05-10 04:21:53 +00:00
|
|
|
|
2016-07-26 07:47:02 +00:00
|
|
|
# override `make_shims` to avoid conflict between pyenv-virtualenv's `envs.bash`
|
2017-04-17 03:59:53 +00:00
|
|
|
# https://github.com/pyenv/pyenv-virtualenv/blob/v20160716/etc/pyenv.d/rehash/envs.bash
|
2016-07-26 07:47:02 +00:00
|
|
|
make_shims() {
|
|
|
|
local file shim
|
|
|
|
for file do
|
|
|
|
shim="${file##*/}"
|
|
|
|
if ! conda_shim "${shim}" 1>&2; then
|
|
|
|
register_shim "$shim"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2016-05-10 04:21:53 +00:00
|
|
|
deregister_conda_shims() {
|
2016-05-24 01:01:41 +00:00
|
|
|
local shim
|
|
|
|
local shims=()
|
|
|
|
for shim in ${registered_shims}; do
|
|
|
|
if ! conda_shim "${shim}" 1>&2; then
|
|
|
|
shims[${#shims[*]}]="${shim}"
|
|
|
|
fi
|
|
|
|
done
|
2016-07-26 07:47:02 +00:00
|
|
|
registered_shims=" ${shims[@]} "
|
2016-05-10 04:21:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if conda_exists; then
|
|
|
|
deregister_conda_shims
|
|
|
|
fi
|