2012-08-31 06:23:41 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
set -e
|
|
|
|
[ -n "$PYENV_DEBUG" ] && set -x
|
|
|
|
|
|
|
|
PYENV_VERSION_FILE="$1"
|
2012-08-31 07:09:46 +00:00
|
|
|
shift
|
2012-08-31 10:39:29 +00:00
|
|
|
PYENV_VERSION=()
|
2012-08-31 07:09:46 +00:00
|
|
|
for version in "$@"; do
|
2012-08-31 10:39:29 +00:00
|
|
|
PYENV_VERSION=("${PYENV_VERSION[@]}" "$version")
|
2012-08-31 07:09:46 +00:00
|
|
|
done
|
2012-08-31 06:23:41 +00:00
|
|
|
|
2012-08-31 10:39:29 +00:00
|
|
|
if [ -z "$PYENV_VERSION" ] || [ -z "$PYENV_VERSION_FILE" ]; then
|
2012-08-31 07:09:46 +00:00
|
|
|
echo "usage: pyenv write-version-file FILENAME VERSIONS..." >&2
|
2012-08-31 06:23:41 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Make sure the specified version is installed.
|
2012-08-31 10:39:29 +00:00
|
|
|
for version in "${PYENV_VERSION[@]}"; do
|
|
|
|
pyenv-prefix "$version" >/dev/null
|
2012-08-31 07:09:46 +00:00
|
|
|
done
|
2012-08-31 06:23:41 +00:00
|
|
|
|
|
|
|
# Write the version out to disk.
|
2012-08-31 07:09:46 +00:00
|
|
|
rm -f "$PYENV_VERSION_FILE"
|
2012-08-31 10:39:29 +00:00
|
|
|
for version in "${PYENV_VERSION[@]}"; do
|
|
|
|
echo "$version" >> "$PYENV_VERSION_FILE"
|
2012-08-31 07:09:46 +00:00
|
|
|
done
|