search commands from python version stack.
users can use multiple python versions at once.
This commit is contained in:
parent
880ea61dd8
commit
8187bc84e3
@ -8,14 +8,19 @@ if [ "$1" = "--complete" ]; then
|
|||||||
exec pyenv-versions --bare
|
exec pyenv-versions --bare
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PYENV_VERSION="$1"
|
PYENV_VERSIONS=($@)
|
||||||
PYENV_VERSION_FILE="${PYENV_ROOT}/version"
|
PYENV_VERSION_FILE="${PYENV_ROOT}/version"
|
||||||
|
|
||||||
if [ -n "$PYENV_VERSION" ]; then
|
if [ -n "$PYENV_VERSIONS" ]; then
|
||||||
pyenv-version-file-write "$PYENV_VERSION_FILE" "$PYENV_VERSION"
|
pyenv-version-file-write "$PYENV_VERSION_FILE" "${PYENV_VERSIONS[@]}"
|
||||||
else
|
else
|
||||||
pyenv-version-file-read "$PYENV_VERSION_FILE" ||
|
IFS=: PYENV_VERSIONS=($(
|
||||||
pyenv-version-file-read "${PYENV_ROOT}/global" ||
|
pyenv-version-file-read "$PYENV_VERSION_FILE" ||
|
||||||
pyenv-version-file-read "${PYENV_ROOT}/default" ||
|
pyenv-version-file-read "${PYENV_ROOT}/global" ||
|
||||||
echo system
|
pyenv-version-file-read "${PYENV_ROOT}/default" ||
|
||||||
|
echo system
|
||||||
|
))
|
||||||
|
for PYENV_VERSION in "${PYENV_VERSIONS[@]}"; do
|
||||||
|
echo "$PYENV_VERSION"
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
@ -44,7 +44,7 @@ global) echo "usage: pyenv global <version>
|
|||||||
|
|
||||||
Sets the global Python version. You can override the global version at
|
Sets the global Python version. You can override the global version at
|
||||||
any time by setting a directory-specific version with \`pyenv local'
|
any time by setting a directory-specific version with \`pyenv local'
|
||||||
or by setting the PYENV_VERSION environment variable.
|
or by setting the PYENV_VERSIONS environment variable.
|
||||||
|
|
||||||
$(print_set_version)"
|
$(print_set_version)"
|
||||||
;;
|
;;
|
||||||
@ -58,14 +58,14 @@ When you run a Python command, pyenv will look for an '.pyenv-version'
|
|||||||
file in the current directory and each parent directory. If no such
|
file in the current directory and each parent directory. If no such
|
||||||
file is found in the tree, pyenv will use the global Python version
|
file is found in the tree, pyenv will use the global Python version
|
||||||
specified with \`pyenv global', or the version specified in the
|
specified with \`pyenv global', or the version specified in the
|
||||||
PYENV_VERSION environment variable.
|
PYENV_VERSIONS environment variable.
|
||||||
|
|
||||||
$(print_set_version)"
|
$(print_set_version)"
|
||||||
;;
|
;;
|
||||||
shell) echo "usage: pyenv shell <version>
|
shell) echo "usage: pyenv shell <version>
|
||||||
pyenv shell --unset
|
pyenv shell --unset
|
||||||
|
|
||||||
Sets a shell-specific Python version by setting the 'PYENV_VERSION'
|
Sets a shell-specific Python version by setting the 'PYENV_VERSIONS'
|
||||||
environment variable in your shell. This version overrides both
|
environment variable in your shell. This version overrides both
|
||||||
project-specific versions and the global version.
|
project-specific versions and the global version.
|
||||||
|
|
||||||
|
@ -9,16 +9,21 @@ if [ "$1" = "--complete" ]; then
|
|||||||
exec pyenv-versions --bare
|
exec pyenv-versions --bare
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PYENV_VERSION="$1"
|
PYENV_VERSIONS=($@)
|
||||||
PYENV_VERSION_FILE=".pyenv-version"
|
PYENV_VERSION_FILE=".pyenv-version"
|
||||||
|
|
||||||
if [ "$PYENV_VERSION" = "--unset" ]; then
|
if [ "$PYENV_VERSIONS" = "--unset" ]; then
|
||||||
rm -f "$PYENV_VERSION_FILE"
|
rm -f "$PYENV_VERSION_FILE"
|
||||||
elif [ -n "$PYENV_VERSION" ]; then
|
elif [ -n "$PYENV_VERSIONS" ]; then
|
||||||
pyenv-version-file-write "$PYENV_VERSION_FILE" "$PYENV_VERSION"
|
pyenv-version-file-write "$PYENV_VERSION_FILE" "${PYENV_VERSIONS[@]}"
|
||||||
else
|
else
|
||||||
pyenv-version-file-read "$PYENV_VERSION_FILE" ||
|
IFS=: PYENV_VERSIONS=($(
|
||||||
{ echo "pyenv: no local version configured for this directory"
|
pyenv-version-file-read "$PYENV_VERSION_FILE" ||
|
||||||
exit 1
|
{ echo "pyenv: no local version configured for this directory"
|
||||||
} >&2
|
exit 1
|
||||||
|
} >&2
|
||||||
|
))
|
||||||
|
for PYENV_VERSION in "${PYENV_VERSIONS[@]}"; do
|
||||||
|
echo "$PYENV_VERSION"
|
||||||
|
done
|
||||||
fi
|
fi
|
||||||
|
@ -9,21 +9,26 @@ if [ "$1" = "--complete" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$1" ]; then
|
if [ -n "$1" ]; then
|
||||||
export PYENV_VERSION="$1"
|
export PYENV_VERSIONS=($@)
|
||||||
elif [ -z "$PYENV_VERSION" ]; then
|
else
|
||||||
PYENV_VERSION="$(pyenv-version-name)"
|
IFS=: PYENV_VERSIONS=($(pyenv-version-name))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$PYENV_VERSION" = "system" ]; then
|
if [ "$PYENV_VERSIONS" = "system" ]; then
|
||||||
PYTHON_PATH="$(pyenv-which python)"
|
PYTHON_PATH="$(pyenv-which python)"
|
||||||
echo "${PYTHON_PATH%/*}"
|
echo "${PYTHON_PATH%/*}"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PYENV_PREFIX_PATH="${PYENV_ROOT}/versions/${PYENV_VERSION}"
|
PYENV_PREFIX_PATHS=()
|
||||||
if [ ! -d "$PYENV_PREFIX_PATH" ]; then
|
for PYENV_VERSION in "${PYENV_VERSIONS[@]}"; do
|
||||||
echo "pyenv: version \`${PYENV_VERSION}' not installed" >&2
|
PYENV_PREFIX_PATH="${PYENV_ROOT}/versions/${PYENV_VERSION}"
|
||||||
exit 1
|
if [ -d "$PYENV_PREFIX_PATH" ]; then
|
||||||
fi
|
PYENV_PREFIX_PATHS=("${PYENV_PREFIX_PATHS[@]}" "$PYENV_PREFIX_PATH")
|
||||||
|
else
|
||||||
|
echo "pyenv: version \`${PYENV_VERSION}' not installed" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
echo "$PYENV_PREFIX_PATH"
|
IFS=: echo "${PYENV_PREFIX_PATHS[*]}"
|
||||||
|
@ -9,24 +9,30 @@ if [ "$1" = "--complete" ]; then
|
|||||||
exec pyenv-versions --bare
|
exec pyenv-versions --bare
|
||||||
fi
|
fi
|
||||||
|
|
||||||
version="$1"
|
versions=()
|
||||||
|
for version in "$@"; do
|
||||||
|
versions=("${versions[@]}" "$version")
|
||||||
|
done
|
||||||
|
|
||||||
if [ -z "$version" ]; then
|
if [ -z "$versions" ]; then
|
||||||
if [ -z "$PYENV_VERSION" ]; then
|
if [ -z "$PYENV_VERSIONS" ]; then
|
||||||
echo "pyenv: no shell-specific version configured" >&2
|
echo "pyenv: no shell-specific version configured" >&2
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
echo "echo \"\$PYENV_VERSION\""
|
echo "echo \"\$PYENV_VERSIONS\""
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$version" = "--unset" ]; then
|
if [ "$versions" = "--unset" ]; then
|
||||||
echo "unset PYENV_VERSION"
|
echo "unset PYENV_VERSIONS"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Make sure the specified version is installed.
|
# Make sure the specified version is installed.
|
||||||
pyenv-prefix "$version" >/dev/null
|
pyenv-prefix $versions >/dev/null
|
||||||
|
|
||||||
echo "export PYENV_VERSION=\"${version}\""
|
{
|
||||||
|
IFS=:
|
||||||
|
echo "export PYENV_VERSIONS=\"${versions[*]}\""
|
||||||
|
}
|
||||||
|
@ -2,4 +2,8 @@
|
|||||||
set -e
|
set -e
|
||||||
[ -n "$PYENV_DEBUG" ] && set -x
|
[ -n "$PYENV_DEBUG" ] && set -x
|
||||||
|
|
||||||
echo "$(pyenv-version-name) (set by $(pyenv-version-origin))"
|
IFS=: PYENV_VERSION_NAMES=($(pyenv-version-name))
|
||||||
|
|
||||||
|
for PYENV_VERSION_NAME in "${PYENV_VERSION_NAMES[@]}"; do
|
||||||
|
echo "$PYENV_VERSION_NAME (set by $(pyenv-version-origin))"
|
||||||
|
done
|
||||||
|
@ -7,16 +7,20 @@ VERSION_FILE="$1"
|
|||||||
if [ -e "$VERSION_FILE" ]; then
|
if [ -e "$VERSION_FILE" ]; then
|
||||||
# Read and print the first non-whitespace word from the specified
|
# Read and print the first non-whitespace word from the specified
|
||||||
# version file.
|
# version file.
|
||||||
version=""
|
versions=()
|
||||||
while read -a words; do
|
while read -a words; do
|
||||||
word="${words[0]}"
|
word="${words[0]}"
|
||||||
if [ -z "$version" ] && [ -n "$word" ]; then
|
if [ -n "$word" ]; then
|
||||||
version="$word"
|
length="${#versions[@]}"
|
||||||
|
versions=("${versions[@]}" "$word")
|
||||||
fi
|
fi
|
||||||
done < <( cat "$VERSION_FILE" && echo )
|
done < <( cat "$VERSION_FILE" && echo )
|
||||||
|
|
||||||
if [ -n "$version" ]; then
|
if [ -n "$versions" ]; then
|
||||||
echo "$version"
|
{
|
||||||
|
IFS=:
|
||||||
|
echo "${versions[*]}"
|
||||||
|
}
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
@ -3,15 +3,24 @@ set -e
|
|||||||
[ -n "$PYENV_DEBUG" ] && set -x
|
[ -n "$PYENV_DEBUG" ] && set -x
|
||||||
|
|
||||||
PYENV_VERSION_FILE="$1"
|
PYENV_VERSION_FILE="$1"
|
||||||
PYENV_VERSION="$2"
|
shift
|
||||||
|
PYENV_VERSIONS=()
|
||||||
|
for version in "$@"; do
|
||||||
|
PYENV_VERSIONS=("${PYENV_VERSIONS[@]}" "$version")
|
||||||
|
done
|
||||||
|
|
||||||
if [ -z "$PYENV_VERSION" ] || [ -z "$PYENV_VERSION_FILE" ]; then
|
if [ -z "$PYENV_VERSIONS" ] || [ -z "$PYENV_VERSION_FILE" ]; then
|
||||||
echo "usage: pyenv write-version-file FILENAME VERSION" >&2
|
echo "usage: pyenv write-version-file FILENAME VERSIONS..." >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Make sure the specified version is installed.
|
# Make sure the specified version is installed.
|
||||||
pyenv-prefix "$PYENV_VERSION" >/dev/null
|
for PYENV_VERSION in "${PYENV_VERSIONS[@]}"; do
|
||||||
|
pyenv-prefix "$PYENV_VERSION" >/dev/null
|
||||||
|
done
|
||||||
|
|
||||||
# Write the version out to disk.
|
# Write the version out to disk.
|
||||||
echo "$PYENV_VERSION" > "$PYENV_VERSION_FILE"
|
rm -f "$PYENV_VERSION_FILE"
|
||||||
|
for PYENV_VERSION in "${PYENV_VERSIONS[@]}"; do
|
||||||
|
echo "$PYENV_VERSION" >> "$PYENV_VERSION_FILE"
|
||||||
|
done
|
||||||
|
@ -2,21 +2,23 @@
|
|||||||
set -e
|
set -e
|
||||||
[ -n "$PYENV_DEBUG" ] && set -x
|
[ -n "$PYENV_DEBUG" ] && set -x
|
||||||
|
|
||||||
if [ -z "$PYENV_VERSION" ]; then
|
if [ -z "$PYENV_VERSIONS" ]; then
|
||||||
PYENV_VERSION_FILE="$(pyenv-version-file)"
|
PYENV_VERSION_FILE="$(pyenv-version-file)"
|
||||||
PYENV_VERSION="$(pyenv-version-file-read "$PYENV_VERSION_FILE" || true)"
|
IFS=: PYENV_VERSIONS=($(pyenv-version-file-read "$PYENV_VERSION_FILE" || true))
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$PYENV_VERSION" ] || [ "$PYENV_VERSION" = "system" ]; then
|
if [ -z "$PYENV_VERSIONS" ] || [ "$PYENV_VERSIONS" = "system" ] ; then
|
||||||
echo "system"
|
echo "system"
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
PYENV_VERSION_PATH="${PYENV_ROOT}/versions/${PYENV_VERSION}"
|
for PYENV_VERSION in "${PYENV_VERSIONS[@]}"; do
|
||||||
|
PYENV_VERSION_PATH="${PYENV_ROOT}/versions/${PYENV_VERSION}"
|
||||||
|
|
||||||
|
if [ ! -d "$PYENV_VERSION_PATH" ]; then
|
||||||
|
echo "pyenv: version \`$PYENV_VERSION' is not installed" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
if [ -d "$PYENV_VERSION_PATH" ]; then
|
IFS=: echo "${PYENV_VERSIONS[*]}"
|
||||||
echo "$PYENV_VERSION"
|
|
||||||
else
|
|
||||||
echo "pyenv: version \`$PYENV_VERSION' is not installed" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
@ -2,23 +2,23 @@
|
|||||||
set -e
|
set -e
|
||||||
[ -n "$PYENV_DEBUG" ] && set -x
|
[ -n "$PYENV_DEBUG" ] && set -x
|
||||||
|
|
||||||
PYENV_VERSION_NAME="$(pyenv-version-name)"
|
IFS=: PYENV_VERSION_NAMES=($(pyenv-version-name))
|
||||||
|
|
||||||
if [ "$1" = "--bare" ]; then
|
if [ "$1" = "--bare" ]; then
|
||||||
hit_prefix=""
|
hit_prefix=""
|
||||||
miss_prefix=""
|
miss_prefix=""
|
||||||
print_version="$PYENV_VERSION_NAME"
|
print_version="$PYENV_VERSION_NAMES"
|
||||||
else
|
else
|
||||||
hit_prefix="* "
|
hit_prefix="* "
|
||||||
miss_prefix=" "
|
miss_prefix=" "
|
||||||
print_version="$(pyenv-version)"
|
print_version="$PYENV_VERSION_NAMES (set by $(pyenv-version-origin))"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for path in "${PYENV_ROOT}/versions/"*; do
|
for path in "${PYENV_ROOT}/versions/"*; do
|
||||||
if [ -d "$path" ]; then
|
if [ -d "$path" ]; then
|
||||||
version="${path##*/}"
|
version="${path##*/}"
|
||||||
|
|
||||||
if [ "$version" == "$PYENV_VERSION_NAME" ]; then
|
if [ "$version" == "$PYENV_VERSION_NAMES" ]; then
|
||||||
echo "${hit_prefix}${print_version}"
|
echo "${hit_prefix}${print_version}"
|
||||||
else
|
else
|
||||||
echo "${miss_prefix}${version}"
|
echo "${miss_prefix}${version}"
|
||||||
|
@ -40,7 +40,7 @@ remove_from_path() {
|
|||||||
echo "${result%:}"
|
echo "${result%:}"
|
||||||
}
|
}
|
||||||
|
|
||||||
PYENV_VERSION="$(pyenv-version-name)"
|
IFS=: PYENV_VERSIONS=($(pyenv-version-name))
|
||||||
PYENV_COMMAND="$1"
|
PYENV_COMMAND="$1"
|
||||||
|
|
||||||
if [ -z "$PYENV_COMMAND" ]; then
|
if [ -z "$PYENV_COMMAND" ]; then
|
||||||
@ -48,12 +48,17 @@ if [ -z "$PYENV_COMMAND" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$PYENV_VERSION" = "system" ]; then
|
for PYENV_VERSION in "${PYENV_VERSIONS[@]}"; do
|
||||||
PATH="$(remove_from_path "${PYENV_ROOT}/shims")"
|
if [ "$PYENV_VERSION" = "system" ]; then
|
||||||
PYENV_COMMAND_PATH="$(command -v "$PYENV_COMMAND")"
|
PATH="$(remote_from_path "${PYENV_ROOT}/shims")"
|
||||||
else
|
PYENV_COMMAND_PATH="$(command -v "$PYENV_COMMAND")"
|
||||||
PYENV_COMMAND_PATH="${PYENV_ROOT}/versions/${PYENV_VERSION}/bin/${PYENV_COMMAND}"
|
else
|
||||||
fi
|
PYENV_COMMAND_PATH="${PYENV_ROOT}/versions/${PYENV_VERSION}/bin/${PYENV_COMMAND}"
|
||||||
|
if [ -x "$PYENV_COMMAND_PATH" ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
for script in $(pyenv-hooks which); do
|
for script in $(pyenv-hooks which); do
|
||||||
source "$script"
|
source "$script"
|
||||||
@ -63,15 +68,5 @@ if [ -x "$PYENV_COMMAND_PATH" ]; then
|
|||||||
echo "$PYENV_COMMAND_PATH"
|
echo "$PYENV_COMMAND_PATH"
|
||||||
else
|
else
|
||||||
echo "pyenv: $PYENV_COMMAND: command not found" >&2
|
echo "pyenv: $PYENV_COMMAND: command not found" >&2
|
||||||
|
|
||||||
versions="$(pyenv-whence "$PYENV_COMMAND" || true)"
|
|
||||||
if [ -n "$versions" ]; then
|
|
||||||
{ echo
|
|
||||||
echo "The \`$1' command exists in these Python versions:"
|
|
||||||
echo "$versions" | sed 's/^/ /g'
|
|
||||||
echo
|
|
||||||
} >&2
|
|
||||||
fi
|
|
||||||
|
|
||||||
exit 127
|
exit 127
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user