2012-08-31 02:23:41 -04:00
|
|
|
#!/usr/bin/env bash
|
2013-01-18 03:41:41 -05:00
|
|
|
# Summary: List all Python versions that contain the given executable
|
|
|
|
# Usage: pyenv whence [--path] <command>
|
|
|
|
|
2012-08-31 02:23:41 -04:00
|
|
|
set -e
|
|
|
|
[ -n "$PYENV_DEBUG" ] && set -x
|
|
|
|
|
|
|
|
# Provide pyenv completions
|
|
|
|
if [ "$1" = "--complete" ]; then
|
|
|
|
echo --path
|
2014-11-30 10:20:53 -05:00
|
|
|
exec pyenv-shims --short
|
2012-08-31 02:23:41 -04:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$1" = "--path" ]; then
|
|
|
|
print_paths="1"
|
|
|
|
shift
|
|
|
|
else
|
|
|
|
print_paths=""
|
|
|
|
fi
|
|
|
|
|
|
|
|
whence() {
|
|
|
|
local command="$1"
|
|
|
|
pyenv-versions --bare | while read version; do
|
|
|
|
path="$(pyenv-prefix "$version")/bin/${command}"
|
|
|
|
if [ -x "$path" ]; then
|
|
|
|
[ "$print_paths" ] && echo "$path" || echo "$version"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
PYENV_COMMAND="$1"
|
|
|
|
if [ -z "$PYENV_COMMAND" ]; then
|
2013-01-18 03:41:41 -05:00
|
|
|
pyenv-help --usage whence >&2
|
2012-08-31 02:23:41 -04:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
result="$(whence "$PYENV_COMMAND")"
|
|
|
|
[ -n "$result" ] && echo "$result"
|