From 5e5428a15453d69d0fe586fbdcca829402bf2491 Mon Sep 17 00:00:00 2001 From: "Karl O. Pinc kop@karlpinc.com" Date: Mon, 23 Oct 2023 19:33:12 +0000 Subject: [PATCH] Use PyPi's API and test individual python packages for update availability We will want to remember to test for pip. Testing for setuptools may eventually become depreciated. --- bin/sokwedb-venv-report | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/bin/sokwedb-venv-report b/bin/sokwedb-venv-report index 9595626..e15e978 100644 --- a/bin/sokwedb-venv-report +++ b/bin/sokwedb-venv-report @@ -44,13 +44,26 @@ cleanup () { trap cleanup EXIT report () { - local project_path=${VENV_PATH}/$1 + # Syntax: report VENVNAME PACKAGE + local venv_name="$1" + local pkg="$2" + local project_path=${VENV_PATH}/"${venv_name}" - ${project_path}/bin/pip list --outdated + local available="$(curl -s https://pypi.org/pypi/${pkg}/json \ + | jq --raw-output .info.version)" + local installed="$(${project_path}/bin/pip list \ + | awk -v pkg="${pkg}" \ + '{if ($1 == pkg) print $2;}')" + if [ "${available}" != "${installed}" ] ; then + printf 'Package %s is at version %s, but version %s is available\n' \ + "${pkg}" "${installed}" "${available}" + fi } # pgadmin4 -report pgadmin4 | grep '^pgadmin4 ' > ${TMPF} +report pgadmin4 pgadmin4 > ${TMPF} +report pgadmin4 pip >> ${TMPF} +report pgadmin4 setuptools >> ${TMPF} if [ -s ${TMPF} ] ; then printf 'Updates available for %s:\n' \ ${VENV_PATH}/pgadmin4 \ -- 2.34.1