Path: blob/main/Tools/scripts/pypi-get-latest-version.sh
16462 views
#!/bin/sh1#2# MAINTAINER: [email protected]34set -e5set -o pipefail67export LC_ALL=C89##10## pypi-get-latest-version.sh: retrieves the latest version of a given Python package as registered on https://pypi.org11##1213# args1415PACKAGE_NAME="$1"1617if [ -z "$PACKAGE_NAME" ]; then18echo "Usage: $0 <package-name>"19exit 120fi2122# check that packaged dependencies are installed2324for dep in jq version_sort; do25if ! which -s $dep; then26echo "error: the '$dep' dependency is missing"27if [ $dep == "jq" ]; then28echo "... please install the 'jq' package"29elif [ $dep == "version_sort" ]; then30echo "... please install the 'libversion' package"31fi32exit 133fi34done353637# MAIN3839fetch -o - https://pypi.python.org/pypi/$PACKAGE_NAME/json 2>/dev/null |40jq -r '.releases | keys[]' |41grep -v dev |42grep -v -E ".*(a|b|rc)[0-9]*$" |43version_sort |44tail -1 ||45! echo "failed to find the Python package '$PACKAGE_NAME'"464748