Date: Thu, 14 Nov 2024 08:29:57 GMT From: Yuri Victorovich <yuri@FreeBSD.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org Subject: git: da7a102f3cdb - main - Tools/scripts: add pypi-get-latest-version.sh Message-ID: <202411140829.4AE8Tvx1083698@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by yuri: URL: https://cgit.FreeBSD.org/ports/commit/?id=da7a102f3cdb22313bd35a76ba8684858063af8b commit da7a102f3cdb22313bd35a76ba8684858063af8b Author: Yuri Victorovich <yuri@FreeBSD.org> AuthorDate: 2024-11-14 08:27:52 +0000 Commit: Yuri Victorovich <yuri@FreeBSD.org> CommitDate: 2024-11-14 08:29:55 +0000 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. --- Tools/scripts/pypi-get-latest-version.sh | 45 ++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) 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'"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202411140829.4AE8Tvx1083698>