From nobody Thu Nov 14 08:29:57 2024 X-Original-To: dev-commits-ports-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Xptcj6kPQz5cKbr; Thu, 14 Nov 2024 08:29:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Xptcj67xpz4mKM; Thu, 14 Nov 2024 08:29:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731572997; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=b89jGz5Zduk7KoV3ZM5lgqZt/4ZjkFx005vj3YhJm04=; b=BZ9lk8NFVTpdHw3SlSOUolNyj4MDKvpfAYnySLoxPnKxWHFO2RUwC0x0UEmmND3h8bsrMq neuASLkW+MtFI3tQN+Tg1BwbTh7zvuxoK9RAuMzpLVfukYWugO5xmmup+mlTLsW3/KVcxl luFEfJHoGVEWrUy6vka7NMQgTb8kGWldYqBbZeZDZNfxAoDwHx7PGJOI+/UVySLCeNSx+6 BM5CQVwQbsHA+Cwxznk2iGuIt6hDtdjU7Wb6gMJvANBUmHSZxQprbqsBacUDxbxVDdIEBA rGmyYVE2vE7/Xk3rnc4ID4K8UnelHOkzXztkhFF7Sj1SOBBaTggc0yl5iyR7Wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1731572997; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=b89jGz5Zduk7KoV3ZM5lgqZt/4ZjkFx005vj3YhJm04=; b=W6deB3D0KohI1krCbM6MfS4j936ldVoSdxy/wW9FscccPCRgfE5fNMpT/MX0lll6s+nKQD NLnoChJo/tuFiCQZDeHErAULBeJSs124RyzrNng7WzFaoZQyMai/5OXdHe/po3wVsNbYq9 b7rMRfg4C76cYL6VE+4Erf1ziNxYaQ2gZ2FwlhITB0op+/IlgCz+WMP0IohG8PbFx32H0m xMYjLtQUGWtgGYKvDYe7t2j1pDajDa674ZewX7Hf8/w+bDuMJVUJ5BKtbJdjcgaHXH1mOH tz9Egic3TRqzoTdOCK6XuwJPBoOshL2E4VFCl4hhp6jVVskvz4aPY3DkzTAK/Q== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1731572997; a=rsa-sha256; cv=none; b=rn6sJVZtv72mjC1D65M9qbJAiqKC89HssiLYsAtW7zXCNxurYnZYTw8emsrbSw+irogyjk 2L19sYoiHzh2k2m/wlygTaAqjwZOpUOIKygV0XtRDjYBz5k9noYevWayfABZMXqACjHVFP TWHqKFX2Kfh4kn9nuAWQsiFw6sdpxBtsPoiOIGZo1y1wY8lxzE90wA++/wpHxqzWrdmCo2 EyPrdRH7x93ZVIW2LISpze8VYaZiPF0ZoziGvrK5/N7XDi/gAMmetOnh8+vaOAw1/ZHcRr zvSYiiT25N3AhZHnGa6apTk/bC5sqhpV9Q6zfDAQW0LRgtsXHC+2F+NAfoj2FA== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Xptcj5Q9gzX5y; Thu, 14 Nov 2024 08:29:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 4AE8TvuE083701; Thu, 14 Nov 2024 08:29:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 4AE8Tvx1083698; Thu, 14 Nov 2024 08:29:57 GMT (envelope-from git) Date: Thu, 14 Nov 2024 08:29:57 GMT Message-Id: <202411140829.4AE8Tvx1083698@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Yuri Victorovich Subject: git: da7a102f3cdb - main - Tools/scripts: add pypi-get-latest-version.sh List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-ports-main@freebsd.org Sender: owner-dev-commits-ports-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: yuri X-Git-Repository: ports X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: da7a102f3cdb22313bd35a76ba8684858063af8b Auto-Submitted: auto-generated The branch main has been updated by yuri: URL: https://cgit.FreeBSD.org/ports/commit/?id=da7a102f3cdb22313bd35a76ba8684858063af8b commit da7a102f3cdb22313bd35a76ba8684858063af8b Author: Yuri Victorovich AuthorDate: 2024-11-14 08:27:52 +0000 Commit: Yuri Victorovich 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 " + 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'"