Last active
December 27, 2024 07:41
-
-
Save russellvt/3250a88a8645db798dc5e865cd45ae47 to your computer and use it in GitHub Desktop.
Show most recent Python (CPython) versions installed under PYEnv
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Show most recent CPython Versions in PyEnv | |
# | |
# Russell M. Van Tassell <[email protected]> | |
# | |
PYENV="$(which pyenv)" | |
PYENV_WHICH=$? | |
if [[ $PYENV_WHICH -ne 0 ]]; then | |
echo "ERROR: Pyenv Does Not seem to be installed" | |
exit $PYENV_WHICH | |
fi | |
PYENV_INST="$PYENV install" | |
PYENV_VERS="$PYENV versions" | |
maj_vers=$($PYENV_INST --list | \ | |
grep '^[ \t][ \t]*[0-9]\.[0-9][0-9]*\.0$' | \ | |
sed 's/\.0//') | |
#all_vers=$($PYENV_INST --list | grep '^[ \t][ \t]*[0-9][0-9\.]*$') | |
for vers in $maj_vers; do | |
echo " Version: $vers" | |
# Latest known version, using sort to make sure things aren't weird... | |
latest_vers=$($PYENV_INST --list | \ | |
grep "^[ \t][ \t]*${vers}\.[0-9][0-9]*$" | \ | |
sort -nr -k3 -t "." | head -1 | |
) | |
# Latest version installed... | |
latest_inst=$($PYENV_VERS | \ | |
grep "^[\* \t][ \t]*${vers}\.[0-9][0-9]*[ \t]*$" | \ | |
sort -nr -k3 -t "." | head -1 | |
) | |
echo " Latest:$latest_vers" | |
if [ ! -z "$latest_inst" ]; then | |
echo "Installed:$latest_inst" | |
else | |
echo "Installed: - none -" | |
fi | |
echo "" | |
done | |
#echo "Major Versions:" | |
#echo "$maj_vers" | |
# vim: noai et syntax=shell: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment