2012-08-31 02:23:41 -04:00
|
|
|
#!/usr/bin/env bash
|
2013-01-18 03:41:41 -05:00
|
|
|
# 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.
|
|
|
|
|
2012-08-31 02:23:41 -04:00
|
|
|
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
|
2013-08-15 09:29:14 -04:00
|
|
|
OLDIFS="$IFS"
|
2014-01-02 12:05:40 -05:00
|
|
|
{ IFS=:
|
|
|
|
export PYENV_VERSION="$*"
|
|
|
|
}
|
2013-08-15 09:29:14 -04:00
|
|
|
IFS="$OLDIFS"
|
2014-01-02 12:05:40 -05:00
|
|
|
elif [ -z "$PYENV_VERSION" ]; then
|
|
|
|
PYENV_VERSION="$(pyenv-version-name)"
|
2012-08-31 02:23:41 -04:00
|
|
|
fi
|
|
|
|
|
2012-08-31 03:09:46 -04:00
|
|
|
PYENV_PREFIX_PATHS=()
|
2014-01-02 12:05:40 -05:00
|
|
|
OLDIFS="$IFS"
|
|
|
|
{ IFS=:
|
|
|
|
for version in ${PYENV_VERSION}; do
|
|
|
|
if [ "$version" = "system" ]; then
|
|
|
|
if PYTHON_PATH="$(pyenv-which python 2>/dev/null)"; then
|
|
|
|
PYENV_PREFIX_PATH="${PYTHON_PATH%/bin/*}"
|
|
|
|
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"
|
2012-08-31 02:23:41 -04:00
|
|
|
|
2013-08-15 09:29:14 -04:00
|
|
|
OLDIFS="$IFS"
|
|
|
|
{ IFS=:
|
|
|
|
echo "${PYENV_PREFIX_PATHS[*]}"
|
|
|
|
}
|
|
|
|
IFS="$OLDIFS"
|