Path: blob/main/Tools/scripts/pypi-get-latest-version.sh
27930 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>"19echo "Example: $0 numpy"20echo "Example: $0 scipy"21exit 122fi2324# check that packaged dependencies are installed2526for dep in jq version_sort; do27if ! which -s $dep; then28echo "error: the '$dep' dependency is missing"29if [ $dep = "jq" ]; then30echo "... please install the 'jq' package"31elif [ $dep = "version_sort" ]; then32echo "... please install the 'libversion' package"33fi34exit 135fi36done373839# MAIN4041fetch -o - https://pypi.python.org/pypi/$PACKAGE_NAME/json 2>/dev/null |42jq -r '.releases | keys[]' |43grep -v dev |44grep -v -E ".*(a|b|rc)[0-9]*$" |45version_sort |46tail -1 ||47! echo "failed to find the Python package '$PACKAGE_NAME'"484950