aboutsummaryrefslogtreecommitdiffstats
path: root/Tools
diff options
context:
space:
mode:
authorYuri Victorovich <yuri@FreeBSD.org>2024-11-14 00:27:52 -0800
committerYuri Victorovich <yuri@FreeBSD.org>2024-11-14 00:29:55 -0800
commitda7a102f3cdb22313bd35a76ba8684858063af8b (patch)
tree6e181bfc3af56dee7dcfb9740d198c0f004eddac /Tools
parent424d6490ef13502c4e18532def9832330146188a (diff)
Tools/scripts: add pypi-get-latest-version.sh
pypi-get-latest-version.sh retrieves the latest version of any Python package as registered on https://pypi.org It makes it easy to check the latest version from the command line.
Diffstat (limited to 'Tools')
-rwxr-xr-xTools/scripts/pypi-get-latest-version.sh45
1 files changed, 45 insertions, 0 deletions
diff --git a/Tools/scripts/pypi-get-latest-version.sh b/Tools/scripts/pypi-get-latest-version.sh
new file mode 100755
index 000000000000..2b7c71e56401
--- /dev/null
+++ b/Tools/scripts/pypi-get-latest-version.sh
@@ -0,0 +1,45 @@
+#!/bin/sh
+#
+# MAINTAINER: yuri@FreeBSD.org
+
+set -e
+set -o pipefail
+
+export LC_ALL=C
+
+##
+## pypi-get-latest-version.sh: retrieves the latest version of a given Python package as registered on https://pypi.org
+##
+
+# args
+
+PACKAGE_NAME="$1"
+
+if [ -z "$PACKAGE_NAME" ]; then
+ echo "Usage: $0 <package-name>"
+ exit 1
+fi
+
+# check that packaged dependencies are installed
+
+for dep in jq version_sort; do
+ if ! which -s $dep; then
+ echo "error: the '$dep' dependency is missing"
+ if [ $dep == "jq" ]; then
+ echo "... please install the 'jq' package"
+ elif [ $dep == "version_sort" ]; then
+ echo "... please install the 'libversion' package"
+ fi
+ exit 1
+ fi
+done
+
+
+# MAIN
+
+fetch -o - https://pypi.python.org/pypi/$PACKAGE_NAME/json 2>/dev/null |
+ jq -r '.releases | keys[]' |
+ grep -v dev |
+ version_sort |
+ tail -1 ||
+ echo "failed to find the Python package '$PACKAGE_NAME'"