mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-21 20:47:00 -05:00
83e5459cfb
All scripts in libexec/ (excluding pyenv) are called through pyenv, therefore the shebang lines are not necessary. On some systems this provides a measurable increase in performance of the shell prompt. Related to pyenv/pyenv-virtualenv#259
56 lines
1.3 KiB
Text
Executable file
56 lines
1.3 KiB
Text
Executable file
# Summary: Display prefix for a Python version
|
|
# Usage: pyenv prefix [<version>]
|
|
#
|
|
# Displays the directory where a Python version is installed. If no
|
|
# version is given, `pyenv prefix' displays the location of the
|
|
# currently selected version.
|
|
|
|
set -e
|
|
[ -n "$PYENV_DEBUG" ] && set -x
|
|
|
|
# Provide pyenv completions
|
|
if [ "$1" = "--complete" ]; then
|
|
echo system
|
|
exec pyenv-versions --bare
|
|
fi
|
|
|
|
if [ -n "$1" ]; then
|
|
OLDIFS="$IFS"
|
|
{ IFS=:
|
|
export PYENV_VERSION="$*"
|
|
}
|
|
IFS="$OLDIFS"
|
|
elif [ -z "$PYENV_VERSION" ]; then
|
|
PYENV_VERSION="$(pyenv-version-name)"
|
|
fi
|
|
|
|
PYENV_PREFIX_PATHS=()
|
|
OLDIFS="$IFS"
|
|
{ IFS=:
|
|
for version in ${PYENV_VERSION}; do
|
|
if [ "$version" = "system" ]; then
|
|
if PYTHON_PATH="$(PYENV_VERSION="${version}" pyenv-which python 2>/dev/null)"; then
|
|
PYENV_PREFIX_PATH="${PYTHON_PATH%/bin/*}"
|
|
PYENV_PREFIX_PATH="${PYENV_PREFIX_PATH:-/}"
|
|
else
|
|
echo "pyenv: system version not found in PATH" >&2
|
|
exit 1
|
|
fi
|
|
else
|
|
PYENV_PREFIX_PATH="${PYENV_ROOT}/versions/${version}"
|
|
fi
|
|
if [ -d "$PYENV_PREFIX_PATH" ]; then
|
|
PYENV_PREFIX_PATHS=("${PYENV_PREFIX_PATHS[@]}" "$PYENV_PREFIX_PATH")
|
|
else
|
|
echo "pyenv: version \`${version}' not installed" >&2
|
|
exit 1
|
|
fi
|
|
done
|
|
}
|
|
IFS="$OLDIFS"
|
|
|
|
OLDIFS="$IFS"
|
|
{ IFS=:
|
|
echo "${PYENV_PREFIX_PATHS[*]}"
|
|
}
|
|
IFS="$OLDIFS"
|