public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-dev@lists.gentoo.org
Cc: "Michał Górny" <mgorny@gentoo.org>
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	[thread overview]
Message-ID: <20240515185347.15937-4-mgorny@gentoo.org> (raw)
In-Reply-To: <20240515185347.15937-1-mgorny@gentoo.org>

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>
---
 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



  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 ` Michał Górny [this message]
2024-05-15 18:49 ` [gentoo-dev] [PATCH 4/7] distutils-r1.eclass: Support reusing prior wheels when compatible Michał Górny
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-4-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