[PATCH 4/5] distutils-r1.eclass: Prefer later wheels for reuse

Michał Górny <[email protected]>
Newsgroups gmane.linux.gentoo.devel
Message-ID <[email protected]>
When choosing the wheel to reuse, prefer the latest wheel that is
compatible with the target.  This matches the behavior of Python
installers, and ensures that when both cp312-abi3 and cp315-abi3.abi3t
wheels are available, the latter is preferred.

Signed-off-by: Michał Górny <[email protected]>
---
 eclass/distutils-r1.eclass | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index f7cb6e78442e8..7704f95515453 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -1230,7 +1230,7 @@ distutils-r1_python_compile() {
 	EOF
 
 	if [[ ${DISTUTILS_ALLOW_WHEEL_REUSE} ]]; then
-		local whl
+		local best_wheel= whl
 		for whl in "${!DISTUTILS_WHEELS[@]}"; do
 			# use only wheels corresponding to the current directory
 			if [[ ${PWD} != ${DISTUTILS_WHEELS["${whl}"]} ]]; then
@@ -1277,10 +1277,14 @@ distutils-r1_python_compile() {
 					.${abi_tag}. == *.abi3t.*
 				)
 			]]; then
-				distutils_wheel_install "${BUILD_DIR}/install" "${whl}"
-				return
+				best_wheel=${whl}
 			fi
 		done
+
+		if [[ -n ${best_wheel} ]]; then
+			distutils_wheel_install "${BUILD_DIR}/install" "${best_wheel}"
+			return
+		fi
 	fi
 
 	distutils_pep517_install "${BUILD_DIR}/install"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.