2019-04-23 10:23:33 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
#
|
2020-03-19 17:35:46 -04:00
|
|
|
# Summary: Set or show the global Python version(s)
|
2013-01-18 17:41:41 +09:00
|
|
|
#
|
2020-03-19 17:35:46 -04:00
|
|
|
# Usage: pyenv global <version> <version2> <..>
|
2013-01-18 17:41:41 +09:00
|
|
|
#
|
2020-03-19 17:35:46 -04:00
|
|
|
# Sets the global Python version(s). You can override the global version at
|
2013-01-18 17:41:41 +09:00
|
|
|
# any time by setting a directory-specific version with `pyenv local'
|
|
|
|
|
# or by setting the `PYENV_VERSION' environment variable.
|
|
|
|
|
#
|
2020-03-19 17:35:46 -04:00
|
|
|
# <version> can be specified multiple times and should be a version
|
|
|
|
|
# tag known to pyenv. The special version string `system' will use
|
|
|
|
|
# your default system Python. Run `pyenv versions' for a list of
|
|
|
|
|
# available Python versions.
|
|
|
|
|
#
|
|
|
|
|
# Example: To enable the python2.7 and python3.7 shims to find their
|
|
|
|
|
# respective executables you could set both versions with:
|
|
|
|
|
#
|
|
|
|
|
# 'pyenv global 3.7.0 2.7.15'
|
|
|
|
|
#
|
|
|
|
|
|
2013-01-18 17:41:41 +09:00
|
|
|
|
2012-08-31 15:23:41 +09:00
|
|
|
set -e
|
|
|
|
|
[ -n "$PYENV_DEBUG" ] && set -x
|
|
|
|
|
|
|
|
|
|
# Provide pyenv completions
|
|
|
|
|
if [ "$1" = "--complete" ]; then
|
|
|
|
|
echo system
|
|
|
|
|
exec pyenv-versions --bare
|
|
|
|
|
fi
|
|
|
|
|
|
2014-09-11 12:59:40 +02:00
|
|
|
versions=("$@")
|
2012-08-31 15:23:41 +09:00
|
|
|
PYENV_VERSION_FILE="${PYENV_ROOT}/version"
|
|
|
|
|
|
2012-09-07 19:16:42 +09:00
|
|
|
if [ -n "$versions" ]; then
|
|
|
|
|
pyenv-version-file-write "$PYENV_VERSION_FILE" "${versions[@]}"
|
2012-08-31 15:23:41 +09:00
|
|
|
else
|
2013-08-15 22:29:14 +09:00
|
|
|
OLDIFS="$IFS"
|
2012-09-07 19:16:42 +09:00
|
|
|
IFS=: versions=($(
|
2012-08-31 16:09:46 +09:00
|
|
|
pyenv-version-file-read "$PYENV_VERSION_FILE" ||
|
|
|
|
|
pyenv-version-file-read "${PYENV_ROOT}/global" ||
|
|
|
|
|
pyenv-version-file-read "${PYENV_ROOT}/default" ||
|
|
|
|
|
echo system
|
|
|
|
|
))
|
2013-08-15 22:29:14 +09:00
|
|
|
IFS="$OLDIFS"
|
2012-09-07 19:16:42 +09:00
|
|
|
for version in "${versions[@]}"; do
|
2012-08-31 19:39:29 +09:00
|
|
|
echo "$version"
|
2012-08-31 16:09:46 +09:00
|
|
|
done
|
2012-08-31 15:23:41 +09:00
|
|
|
fi
|