Skip to content

Instantly share code, notes, and snippets.

@stas00
Created October 25, 2018 02:41
Show Gist options
  • Save stas00/b753184608e3f570ce0e670fe2a7829a to your computer and use it in GitHub Desktop.
Save stas00/b753184608e3f570ce0e670fe2a7829a to your computer and use it in GitHub Desktop.
poll pypi servers until a desired version of a specif cpackage becomes available
#!/usr/bin/env bash
#set -x
package="fastai"
ver="1.0.14"
# is_pip_ver_available "1.0.14"
# returns 1 if yes, 0 otherwise
function is_pip_ver_available() {
local ver="$1"
local out="$(pip install $package== |& grep $ver)"
if [[ -n "$out" ]]; then
echo 1
else
echo 0
fi
}
function wait_till_pip_ver_available() {
if [[ $(is_pip_ver_available $ver) == "1" ]]; then
echo "$package-$ver is available on pypi"
return 1
fi
COUNTER=0
echo "waiting for $package-$ver package to become visible on pypi:"
while [[ $(is_pip_ver_available $ver) != "1" ]]; do
echo -en "\\rwaiting: $COUNTER secs"
COUNTER=$[$COUNTER +5]
sleep 5
done
echo -e "\rwaited: $COUNTER secs "
echo -e "$package-$ver is now available on pypi"
}
wait_till_pip_ver_available $ver
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment