Skip to content

Instantly share code, notes, and snippets.

@tweakimp
Created September 24, 2019 05:36
Show Gist options
  • Save tweakimp/7c2d4a1c3689ad53260e4940aab6ecd1 to your computer and use it in GitHub Desktop.
Save tweakimp/7c2d4a1c3689ad53260e4940aab6ecd1 to your computer and use it in GitHub Desktop.
pip updater
#!/usr/bin/env bash
echo "PIP PACKAGE UPDATER"
going=true
while $going
do
read -n 1 -p "`echo $'\n[1] Force update all packages'``echo $'\n[2] Check for updates'``echo $'\n[5] Update packages considering dependencies'``echo $'\n[9] Force reinstall all packages'``echo $'\n[Q] Quit'``echo $'\n> '`" ans;
echo $'\n'
case $ans in
1)
echo $'Force updating all packages...\n'
py -3.7 -m pip install --pre --no-cache-dir --upgrade --upgrade-strategy 'eager' $(py -3.7 -m pip freeze | awk '{split($0, a, "=="); print a[1]}')
going=false;;
2) echo $'Checking for updates...\n'
py -3.7 -m pip list --pre --outdated;;
5)
echo $'Updating packages considering dependencies ...\n'
py -3.7 -m pip install --no-cache-dir --upgrade $(py -3.7 -m pip | awk '{split($0, a, "=="); print a[1]}')
going=false;;
9)
echo $'Force reinstalling all packages...\n'
py -3.7 -m pip install --pre --upgrade --force-reinstall --no-cache-dir -I $(py -3.7 -m pip freeze | awk '{split($0, a, "=="); print a[1]}')
going=false;;
q|Q)
exit 0;;
*)
reset
echo "$ans is not a valid option.`echo $'\n'`";;
esac
done
echo $'\n'
read -n 1 -s -r -p "Press any key to exit."
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment