mirror of
https://github.com/pyenv/pyenv.git
synced 2024-11-21 20:47:00 -05:00
40 lines
954 B
Bash
Executable file
40 lines
954 B
Bash
Executable file
#!/usr/bin/env bash
|
|
#
|
|
# Summary: Run an executable with the selected Python version
|
|
#
|
|
# Usage: pyenv exec <command> [arg1 arg2...]
|
|
#
|
|
# Runs an executable by first preparing PATH so that the selected Python
|
|
# version's `bin' directory is at the front.
|
|
#
|
|
# For example, if the currently selected Python version is 2.7.7:
|
|
# pyenv exec pip install -rrequirements.txt
|
|
#
|
|
# is equivalent to:
|
|
# PATH="$PYENV_ROOT/versions/2.7.7/bin:$PATH" pip install -rrequirements.txt
|
|
|
|
set -e
|
|
[ -n "$PYENV_DEBUG" ] && set -x
|
|
|
|
# Provide pyenv completions
|
|
if [ "$1" = "--complete" ]; then
|
|
exec pyenv shims --short
|
|
fi
|
|
|
|
PYENV_COMMAND="$1"
|
|
|
|
if [ -z "$PYENV_COMMAND" ]; then
|
|
pyenv-help --usage exec >&2
|
|
exit 1
|
|
fi
|
|
|
|
PYENV_COMMAND_PATH="$(pyenv-which "$PYENV_COMMAND")"
|
|
PYENV_BIN_PATH="${PYENV_COMMAND_PATH%/*}"
|
|
|
|
for script in $(pyenv-hooks exec); do
|
|
source "$script"
|
|
done
|
|
|
|
shift 1
|
|
export PATH="${PYENV_BIN_PATH}:${PATH}"
|
|
exec -a "$PYENV_COMMAND" "$PYENV_COMMAND_PATH" "$@"
|