From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 400A21581D3 for ; Mon, 20 May 2024 17:02:41 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 58CAFE2A32; Mon, 20 May 2024 17:02:40 +0000 (UTC) Received: from smtp.gentoo.org (dev.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 41819E2A32 for ; Mon, 20 May 2024 17:02:40 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (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) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 86AE033BE12 for ; Mon, 20 May 2024 17:02:39 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id EDA5D1AED for ; Mon, 20 May 2024 17:02:37 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <1716224203.314c6b009037cf21ddfb35b6c372c5dd3819e0c5.mgorny@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/distutils-r1.eclass X-VCS-Directories: eclass/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: 314c6b009037cf21ddfb35b6c372c5dd3819e0c5 X-VCS-Branch: master Date: Mon, 20 May 2024 17:02:37 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 68a15479-8878-41d0-a9a8-2d185cf928da X-Archives-Hash: 62b4742ccc9ecf2a6fb3c75921b38f0c commit: 314c6b009037cf21ddfb35b6c372c5dd3819e0c5 Author: Michał Górny gentoo org> AuthorDate: Tue May 14 12:09:24 2024 +0000 Commit: Michał Górny gentoo org> CommitDate: Mon May 20 16:56:43 2024 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=314c6b00 distutils-r1.eclass: Support reusing prior wheels when compatible Support reusing the wheels built for earlier Python implementations if they are compatible with the subsequent implementations being built. This includes pure Python wheels in packages that do not set DISTUTILS_EXT, and stable ABI wheels. Closes: https://bugs.gentoo.org/931689 Signed-off-by: Michał Górny gentoo.org> eclass/distutils-r1.eclass | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass index 29e901720e6c..a8f9817a3cf0 100644 --- a/eclass/distutils-r1.eclass +++ b/eclass/distutils-r1.eclass @@ -189,6 +189,18 @@ esac # ${DISTUTILS_DEPS}" # @CODE +# @ECLASS_VARIABLE: DISTUTILS_ALLOW_WHEEL_REUSE +# @DEFAULT_UNSET +# @USER_VARIABLE +# @DESCRIPTION: +# If set to a non-empty value, the eclass is allowed to reuse a wheel +# that was built for a prior Python implementation, provided that it is +# compatible with the current one, rather than building a new one. +# +# This is an optimization that can avoid the overhead of calling into +# the build system in pure Python packages and packages using the stable +# Python ABI. + if [[ -z ${_DISTUTILS_R1_ECLASS} ]]; then _DISTUTILS_R1_ECLASS=1 @@ -1585,6 +1597,32 @@ distutils-r1_python_compile() { esac if [[ ${DISTUTILS_USE_PEP517} ]]; then + if [[ ${DISTUTILS_ALLOW_WHEEL_REUSE} ]]; then + local whl + for whl in "${!DISTUTILS_WHEELS[@]}"; do + # use only wheels corresponding to the current directory + if [[ ${PWD} != ${DISTUTILS_WHEELS["${whl}"]} ]]; then + continue + fi + + # 1. Use pure Python wheels only if we're not expected + # to build extensions. Otherwise, we may end up + # not building the extension at all when e.g. PyPy3 + # is built without one. + # + # 2. For CPython, we can reuse stable ABI wheels. Note + # that this relies on the assumption that we're building + # from the oldest to the newest implementation, + # and the wheels are forward-compatible. + if [[ ( ! ${DISTUTILS_EXT} && ${whl} == *py3-none-any* ) || + ( ${EPYTHON} == python* && ${whl} == *-abi3-* ) ]] + then + distutils_wheel_install "${BUILD_DIR}/install" "${whl}" + return + fi + done + fi + distutils_pep517_install "${BUILD_DIR}/install" DISTUTILS_WHEELS+=( "${DISTUTILS_WHEEL_PATH}" "${PWD}" ) fi