From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: "Michał Górny" <mgorny@gentoo.org>
Subject: [gentoo-dev] [PATCH 4/7] distutils-r1.eclass: Support reusing prior wheels when compatible
Date: Wed, 15 May 2024 20:49:54 +0200 [thread overview]
Message-ID: <20240515185347.15937-5-mgorny@gentoo.org> (raw)
In-Reply-To: <20240515185347.15937-1-mgorny@gentoo.org>
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 <mgorny@gentoo.org>
---
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
next prev parent reply other threads:[~2024-05-15 18:54 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-15 18:49 [gentoo-dev] [PATCH 0/7] distutils-r1.eclass: wheel reuse optimization, EPYTEST_FLAGS and scikit-build-core updates Michał Górny
2024-05-15 18:49 ` [gentoo-dev] [PATCH 1/7] distutils-r1.eclass: Set DISTUTILS_WHEEL_PATH in PEP517 install Michał Górny
2024-05-15 18:49 ` [gentoo-dev] [PATCH 2/7] distutils-r1.eclass: Store created wheels in DISTUTILS_WHEELS Michał Górny
2024-05-15 18:49 ` [gentoo-dev] [PATCH 3/7] distutils-r1.eclass: Add a QA warning for pure Python file mismatch Michał Górny
2024-05-15 18:49 ` Michał Górny [this message]
2024-05-15 18:49 ` [gentoo-dev] [PATCH 5/7] python-utils-r1.eclass: Support passing EPYTEST_FLAGS Michał Górny
2024-05-15 18:49 ` [gentoo-dev] [PATCH 6/7] distutils-r1.eclass: Update scikit-build-core to 0.9.4 Michał Górny
2024-05-15 18:49 ` [gentoo-dev] [PATCH 7/7] distutils-r1.eclass: Pass ninja options to scikit-build-core Michał Górny
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240515185347.15937-5-mgorny@gentoo.org \
--to=mgorny@gentoo.org \
--cc=gentoo-dev@lists.gentoo.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox