From 0c9829c65f3b06aafd00ccf6835b0aefec80eb0a Mon Sep 17 00:00:00 2001 From: Josef Schlehofer Date: Sun, 27 Sep 2026 17:52:18 +0200 Subject: [PATCH] python3: match packages by pattern in version check override The override lists every python3 package by name, so it has to change whenever the package set does, and it cannot be used as is on branches that build a different set, like libpython3-3.13 and python3-email on openwrt-25.12. Check the interpreter, python3-dev and libpython3-X.Y against the version, and accept the standard library modules and -src packages by pattern, since they ship no executables. python3-dev now gets a real check through python3-config and patchlevel.h, because python3-config prints no version. Signed-off-by: Josef Schlehofer (cherry picked from commit 9274fde0baf0e9f34d7b0e9b33054c4fff1ad3e0) [take the new file, openwrt-25.12 does not have the package list from 9d69e4fa2] Signed-off-by: Josef Schlehofer --- lang/python/python3/test-version.sh | 45 ++++++++++++++--------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/lang/python/python3/test-version.sh b/lang/python/python3/test-version.sh index c18da41931..3a69b569d8 100755 --- a/lang/python/python3/test-version.sh +++ b/lang/python/python3/test-version.sh @@ -1,35 +1,34 @@ #!/bin/sh -# shellckeck shell=busybox +# shellcheck shell=busybox + +# PYTHON3_VERSION from python3-version.mk, for example 3.13 +PYTHON3_VERSION="${PKG_VERSION%.*}" case "$PKG_NAME" in python3|\ python3-base|\ python3-light) - python3 --version | grep -Fx "Python $PKG_VERSION" + "python$PYTHON3_VERSION" --version | grep -Fx "Python $PKG_VERSION" && + python3 --version | grep -Fx "Python $PKG_VERSION" ;; -python3-asyncio|\ -python3-base-src|\ -python3-codecs|\ -python3-ctypes|\ -python3-dbm|\ -python3-decimal|\ -python3-dev|\ -python3-light-src|\ -python3-logging|\ -python3-lzma|\ -python3-multiprocessing|\ -python3-ncurses|\ -python3-openssl|\ -python3-pydoc|\ -python3-readline|\ -python3-sqlite3|\ -python3-unittest|\ -python3-urllib|\ -python3-uuid|\ -python3-venv|\ -python3-xml) +python3-dev) + # python3-config prints no version, so check that it points to the + # headers of this version + "python$PYTHON3_VERSION-config" --includes | + grep -F -e "-I/usr/include/python$PYTHON3_VERSION" && + grep '^#define PY_VERSION ' "/usr/include/python$PYTHON3_VERSION/patchlevel.h" | + grep -F "\"$PKG_VERSION\"" + ;; + +libpython3-*) + # The package name carries the ABI version + [ "$PKG_NAME" = "libpython3-$PYTHON3_VERSION" ] + ;; + +python3-*) + # Standard library modules and -src packages ship no executables exit 0 ;;