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 5962D1581D3 for ; Wed, 15 May 2024 18:54:40 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 709422BC04B; Wed, 15 May 2024 18:53:55 +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 1E1D62BC048 for ; Wed, 15 May 2024 18:53:55 +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 3/7] distutils-r1.eclass: Add a QA warning for pure Python file mismatch Date: Wed, 15 May 2024 20:49:53 +0200 Message-ID: <20240515185347.15937-4-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: 1aedb2d5-e054-4c39-9da5-05d549c0f534 X-Archives-Hash: 4288135a42b0e1ac86544926c978f420 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 --- eclass/distutils-r1.eclass | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass index 89223b248157..f014a184885a 100644 --- a/eclass/distutils-r1.eclass +++ b/eclass/distutils-r1.eclass @@ -2021,6 +2021,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: @@ -2055,6 +2093,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 } -- 2.45.1