2013-01-18 03:41:41 -05:00
|
|
|
# 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.
|
|
|
|
|
2012-08-31 02:23:41 -04:00
|
|
|
set -e
|
|
|
|
[ -n "$PYENV_DEBUG" ] && set -x
|
|
|
|
|
|
|
|
# Provide pyenv completions
|
|
|
|
if [ "$1" = "--complete" ]; then
|
|
|
|
echo --unset
|
|
|
|
echo system
|
|
|
|
exec pyenv-versions --bare
|
|
|
|
fi
|
|
|
|
|
2014-09-11 06:59:40 -04:00
|
|
|
versions=("$@")
|
2012-08-31 02:23:41 -04:00
|
|
|
|
2012-09-07 06:16:42 -04:00
|
|
|
if [ "$versions" = "--unset" ]; then
|
2016-03-03 19:00:53 -05:00
|
|
|
rm -f .python-version
|
2012-09-07 06:16:42 -04:00
|
|
|
elif [ -n "$versions" ]; then
|
2014-01-02 12:05:40 -05:00
|
|
|
pyenv-version-file-write .python-version "${versions[@]}"
|
2012-08-31 02:23:41 -04:00
|
|
|
else
|
2016-03-03 19:00:53 -05:00
|
|
|
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
|
2012-08-31 02:23:41 -04:00
|
|
|
fi
|