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