diff options
author | Michał Górny <mgorny@gentoo.org> | 2024-05-14 13:13:52 +0200 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2024-05-20 18:56:42 +0200 |
commit | a3895e6ab84b171c1470ac790b8002d9d9a820de (patch) | |
tree | 642dfefb6c9ccd6014dbf5ad1f032a3de0acda7e /eclass | |
parent | distutils-r1.eclass: Store created wheels in DISTUTILS_WHEELS (diff) | |
download | gentoo-a3895e6ab84b171c1470ac790b8002d9d9a820de.tar.gz gentoo-a3895e6ab84b171c1470ac790b8002d9d9a820de.tar.bz2 gentoo-a3895e6ab84b171c1470ac790b8002d9d9a820de.zip |
distutils-r1.eclass: Add a QA warning for pure Python file mismatch
If the package is creating at least one pure Python wheel, check whether
the baseline package contents (i.e. everything but compiled Python
modules, extensions and .dist-info) match between implementations.
This is meant to ensure that we can safely optimize builds by reusing
pure Python wheels from previous builds.
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/distutils-r1.eclass | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass index 955c41fe4e2d..29e901720e6c 100644 --- a/eclass/distutils-r1.eclass +++ b/eclass/distutils-r1.eclass @@ -2022,6 +2022,44 @@ distutils-r1_src_configure() { return ${ret} } +# @FUNCTION: _distutils-r1_compare_installed_files +# @INTERNAL +# @DESCRIPTION: +# Verify the the match between files installed between this and previous +# implementation. +_distutils-r1_compare_installed_files() { + debug-print-function ${FUNCNAME} "${@}" + + # QA check requires diff(1). + if ! type -P diff &>/dev/null; then + return + fi + + # Perform the check only if at least one potentially reusable wheel + # has been produced. Nonpure packages (e.g. NumPy) may install + # interpreter configuration details into sitedir. + if [[ ${!DISTUTILS_WHEELS[*]} != *-none-any.whl* && + ${!DISTUTILS_WHEELS[*]} != *-abi3-*.whl ]]; then + return + fi + + local sitedir=${BUILD_DIR}/install$(python_get_sitedir) + if [[ -n ${_DISTUTILS_PREVIOUS_SITE} ]]; then + diff -dur \ + --exclude=__pycache__ \ + --exclude='*.dist-info' \ + --exclude="*$(get_modname)" \ + "${_DISTUTILS_PREVIOUS_SITE}" "${sitedir}" + if [[ ${?} -ne 0 ]]; then + eqawarn "Package creating at least one pure Python wheel installs different" + eqawarn "Python files between implementations. See diff in build log, above" + eqawarn "this message." + fi + fi + + _DISTUTILS_PREVIOUS_SITE=${sitedir} +} + # @FUNCTION: _distutils-r1_post_python_compile # @INTERNAL # @DESCRIPTION: @@ -2056,6 +2094,8 @@ _distutils-r1_post_python_compile() { find "${bindir}" -type f -exec sed -i \ -e "1s@^#!\(${EPREFIX}/usr/bin/\(python\|pypy\)\)@#!${root}\1@" \ {} + || die + + _distutils-r1_compare_installed_files fi } |