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 52F1D1581D3 for ; Wed, 15 May 2024 18:54:55 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 726C82BC057; Wed, 15 May 2024 18:53:56 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (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 343412BC054 for ; Wed, 15 May 2024 18:53:56 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-dev@lists.gentoo.org Cc: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-dev] [PATCH 4/7] distutils-r1.eclass: Support reusing prior wheels when compatible Date: Wed, 15 May 2024 20:49:54 +0200 Message-ID: <20240515185347.15937-5-mgorny@gentoo.org> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240515185347.15937-1-mgorny@gentoo.org> References: <20240515185347.15937-1-mgorny@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Archives-Salt: 8941db22-0028-42e7-bfeb-68d502b3eb83 X-Archives-Hash: b3cf738baf2cee83e15aee549c70ebf0 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 --- eclass/distutils-r1.eclass | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass index f014a184885a..e4d53083124e 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 @@ -1584,6 +1596,27 @@ distutils-r1_python_compile() { esac if [[ ${DISTUTILS_USE_PEP517} ]]; then + if [[ ${DISTUTILS_ALLOW_WHEEL_REUSE} ]]; then + local whl + for whl in "${DISTUTILS_WHEELS[@]}"; do + # 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}" ) fi -- 2.45.1