[PATCH 5/5] distutils-r1.eclass: Add a Python tag safety check for wheel reuse
Michał Górny <[email protected]>
| Newsgroups | gmane.linux.gentoo.devel |
|---|---|
| Message-ID | <[email protected]> |
Add a safety check verifying whether all the previously built wheels were built for a Python tag that's not newer than the current implementation. Given we are always building from the oldest version to newest, this must always be true and we fail immediately if it is not. Note that since we're merely checking this particular aspect, we do not check whether the combination of the Python tag and the ABI tag is compatible. Signed-off-by: Michał Górny <[email protected]> --- eclass/distutils-r1.eclass | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass index 7704f95515453..fb1e2a9c311a3 100644 --- a/eclass/distutils-r1.eclass +++ b/eclass/distutils-r1.eclass @@ -1250,6 +1250,28 @@ distutils-r1_python_compile() { whl_fn=${whl_fn%-*} local python_tag=${whl_fn##*-} + # Verify whether the Python tag is compatible. We should + # be running from the oldest to the newest Python version, + # so it should always hold. We short-circuit py3 tag. + if [[ .${python_tag}. != *.py3.* ]]; then + [[ ${EPYTHON} != python3.* ]] && + die "Update the python_tag check for ${EPYTHON}" + local minor=${EPYTHON#python3.} + minor=${minor%t} + local is_compatible= + while [[ ${minor} -ge 0 ]]; do + if [[ + .${python_tag}. == *.cp3${minor}.* || + .${python_tag}. == *.py3${minor}.* + ]]; then + is_compatible=1 + fi + : $(( minor-- )) + done + [[ ! ${is_compatible} ]] && + die "Incompatible Python tag found in ${whl_fn}" + fi + if [[ # Use pure Python wheels only if we're not expected to # build extensions. Otherwise, we may end up not