2019-04-23 14:23:33 +00:00
|
|
|
#!/usr/bin/env bash
|
2022-03-09 02:33:01 +00:00
|
|
|
# Summary: Display prefixes for Python versions
|
|
|
|
# Usage: pyenv prefix [<version>...]
|
2013-01-18 08:41:41 +00:00
|
|
|
#
|
2022-03-09 02:33:01 +00:00
|
|
|
# Displays the directories where the given Python versions are installed,
|
|
|
|
# separated by colons. If no version is given, `pyenv prefix' displays the
|
|
|
|
# locations of the currently selected versions.
|
2013-01-18 08:41:41 +00:00
|
|
|
|
2012-08-31 06:23:41 +00: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 13:29:14 +00:00
|
|
|
OLDIFS="$IFS"
|
2014-01-02 17:05:40 +00:00
|
|
|
{ IFS=:
|
|
|
|
export PYENV_VERSION="$*"
|
|
|
|
}
|
2013-08-15 13:29:14 +00:00
|
|
|
IFS="$OLDIFS"
|
2014-01-02 17:05:40 +00:00
|
|
|
elif [ -z "$PYENV_VERSION" ]; then
|
|
|
|
PYENV_VERSION="$(pyenv-version-name)"
|
2012-08-31 06:23:41 +00:00
|
|
|
fi
|
|
|
|
|
2012-08-31 07:09:46 +00:00
|
|
|
PYENV_PREFIX_PATHS=()
|
2014-01-02 17:05:40 +00:00
|
|
|
OLDIFS="$IFS"
|
|
|
|
{ IFS=:
|
|
|
|
for version in ${PYENV_VERSION}; do
|
|
|
|
if [ "$version" = "system" ]; then
|
2020-09-21 15:53:09 +00:00
|
|
|
if PYTHON_PATH="$(PYENV_VERSION="${version}" pyenv-which python 2>/dev/null)" || \
|
|
|
|
PYTHON_PATH="$(PYENV_VERSION="${version}" pyenv-which python3 2>/dev/null)" || \
|
|
|
|
PYTHON_PATH="$(PYENV_VERSION="${version}" pyenv-which python2 2>/dev/null)"; then
|
2021-09-15 17:00:49 +00:00
|
|
|
shopt -s extglob
|
|
|
|
# In some distros (Arch), Python can be found in sbin as well as bin
|
|
|
|
PYENV_PREFIX_PATH="${PYTHON_PATH%/?(s)bin/*}"
|
2016-07-21 02:45:27 +00:00
|
|
|
PYENV_PREFIX_PATH="${PYENV_PREFIX_PATH:-/}"
|
2014-01-02 17:05:40 +00:00
|
|
|
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 06:23:41 +00:00
|
|
|
|
2013-08-15 13:29:14 +00:00
|
|
|
OLDIFS="$IFS"
|
|
|
|
{ IFS=:
|
|
|
|
echo "${PYENV_PREFIX_PATHS[*]}"
|
|
|
|
}
|
|
|
|
IFS="$OLDIFS"
|