mirror of
https://github.com/pyenv/pyenv-virtualenv.git
synced 2025-11-08 11:33:55 -05:00
add a script to hook source activate for Anaconda/Miniconda (#103)
This commit is contained in:
@@ -9,6 +9,26 @@
|
|||||||
set -e
|
set -e
|
||||||
[ -n "$PYENV_DEBUG" ] && set -x
|
[ -n "$PYENV_DEBUG" ] && set -x
|
||||||
|
|
||||||
|
resolve_link() {
|
||||||
|
$(type -p greadlink readlink | head -1) "$1"
|
||||||
|
}
|
||||||
|
|
||||||
|
abs_dirname() {
|
||||||
|
local cwd="$(pwd)"
|
||||||
|
local path="$1"
|
||||||
|
|
||||||
|
while [ -n "$path" ]; do
|
||||||
|
cd "${path%/*}"
|
||||||
|
local name="${path##*/}"
|
||||||
|
path="$(resolve_link "$name" || true)"
|
||||||
|
done
|
||||||
|
|
||||||
|
pwd
|
||||||
|
cd "$cwd"
|
||||||
|
}
|
||||||
|
|
||||||
|
PYENV_VIRTUALENV_INSTALL_PREFIX="$(dirname "$(abs_dirname "$0")")"
|
||||||
|
|
||||||
print=""
|
print=""
|
||||||
for args in "$@"
|
for args in "$@"
|
||||||
do
|
do
|
||||||
@@ -65,10 +85,16 @@ fi
|
|||||||
|
|
||||||
case "$shell" in
|
case "$shell" in
|
||||||
fish )
|
fish )
|
||||||
echo "setenv PYENV_VIRTUALENV_INIT 1;"
|
cat <<EOS
|
||||||
|
setenv PATH '${PYENV_VIRTUALENV_ROOT:-${PYENV_VIRTUALENV_INSTALL_PREFIX}}/shims' \$PATH;
|
||||||
|
setenv PYENV_VIRTUALENV_INIT 1;
|
||||||
|
EOS
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
echo "export PYENV_VIRTUALENV_INIT=1;"
|
cat <<EOS
|
||||||
|
export PATH="${PYENV_VIRTUALENV_ROOT:-${PYENV_VIRTUALENV_INSTALL_PREFIX}}/shims:${PATH}";
|
||||||
|
export PYENV_VIRTUALENV_INIT=1;
|
||||||
|
EOS
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,9 @@ if [ -z "${PREFIX}" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
BIN_PATH="${PREFIX}/bin"
|
BIN_PATH="${PREFIX}/bin"
|
||||||
|
SHIMS_PATH="${PREFIX}/shims"
|
||||||
|
|
||||||
mkdir -p "$BIN_PATH"
|
mkdir -p "$BIN_PATH"
|
||||||
|
|
||||||
install -p bin/* "$BIN_PATH"
|
install -p bin/* "$BIN_PATH"
|
||||||
|
install -p shims/* "$SHIMS_PATH"
|
||||||
|
|||||||
7
shims/activate
Executable file
7
shims/activate
Executable file
@@ -0,0 +1,7 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
if [[ "$0" != "${BASH_SOURCE}" ]]; then
|
||||||
|
eval "$(pyenv sh-activate --verbose "$@" || true)"
|
||||||
|
else
|
||||||
|
echo "pyenv-virtualenv: activate must be sourced. Run 'source activate envname' instead of 'activate envname'" 1>&2
|
||||||
|
false
|
||||||
|
fi
|
||||||
Reference in New Issue
Block a user