mirror of
https://github.com/pyenv/pyenv.git
synced 2024-12-22 21:12:29 +00:00
83e5459cfb
All scripts in libexec/ (excluding pyenv) are called through pyenv, therefore the shebang lines are not necessary. On some systems this provides a measurable increase in performance of the shell prompt. Related to pyenv/pyenv-virtualenv#259
46 lines
1.4 KiB
Text
Executable file
46 lines
1.4 KiB
Text
Executable file
# Summary: Set or show the local application-specific Python version
|
|
#
|
|
# Usage: pyenv local <version>
|
|
# pyenv local --unset
|
|
#
|
|
# Sets the local application-specific Python version by writing the
|
|
# version name to a file named `.python-version'.
|
|
#
|
|
# When you run a Python command, pyenv will look for a `.python-version'
|
|
# 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
|
|
# specified with `pyenv global'. A version specified with the
|
|
# `PYENV_VERSION' environment variable takes precedence over local
|
|
# and global versions.
|
|
#
|
|
# <version> should be a string matching a Python version known to pyenv.
|
|
# The special version string `system' will use your default system Python.
|
|
# Run `pyenv versions' for a list of available Python versions.
|
|
|
|
set -e
|
|
[ -n "$PYENV_DEBUG" ] && set -x
|
|
|
|
# Provide pyenv completions
|
|
if [ "$1" = "--complete" ]; then
|
|
echo --unset
|
|
echo system
|
|
exec pyenv-versions --bare
|
|
fi
|
|
|
|
versions=("$@")
|
|
|
|
if [ "$versions" = "--unset" ]; then
|
|
rm -f .python-version
|
|
elif [ -n "$versions" ]; then
|
|
pyenv-version-file-write .python-version "${versions[@]}"
|
|
else
|
|
if version_file="$(pyenv-version-file "$PWD")"; then
|
|
IFS=: versions=($(pyenv-version-file-read "$version_file"))
|
|
for version in "${versions[@]}"; do
|
|
echo "$version"
|
|
done
|
|
else
|
|
echo "pyenv: no local version configured for this directory" >&2
|
|
exit 1
|
|
fi
|
|
fi
|