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 321B615800A for ; Sun, 6 Aug 2023 06:42:34 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 57E2E2BC013; Sun, 6 Aug 2023 06:42:33 +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 3B37D2BC013 for ; Sun, 6 Aug 2023 06:42:33 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 2713F340E53 for ; Sun, 6 Aug 2023 06:42:32 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 6CF6BF15 for ; Sun, 6 Aug 2023 06:42:30 +0000 (UTC) From: "Michał Górny" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Michał Górny" Message-ID: <1691304147.cf582a6d842973915d1cec5c05a8b4c311b78288.mgorny@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/python-utils-r1.eclass X-VCS-Directories: eclass/ X-VCS-Committer: mgorny X-VCS-Committer-Name: Michał Górny X-VCS-Revision: cf582a6d842973915d1cec5c05a8b4c311b78288 X-VCS-Branch: master Date: Sun, 6 Aug 2023 06:42:30 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: d3a23e1b-0519-46c7-9708-6d54d762d791 X-Archives-Hash: c6cfefb4314b1f2e4c499ca145660228 commit: cf582a6d842973915d1cec5c05a8b4c311b78288 Author: Michał Górny gentoo org> AuthorDate: Sat Aug 5 06:59:39 2023 +0000 Commit: Michał Górny gentoo org> CommitDate: Sun Aug 6 06:42:27 2023 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cf582a6d python-utils-r1.eclass: Check for occluded packages before testing Add a check for installed packages being occluded by the working directory when calling epytest and eunittest. This is primarily meant to detect C extensions being missed. Signed-off-by: Michał Górny gentoo.org> Closes: https://github.com/gentoo/gentoo/pull/32181 Signed-off-by: Michał Górny gentoo.org> eclass/python-utils-r1.eclass | 51 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass index 2555ce12d066..27157a003ab2 100644 --- a/eclass/python-utils-r1.eclass +++ b/eclass/python-utils-r1.eclass @@ -1231,6 +1231,55 @@ _python_check_EPYTHON() { fi } +# @FUNCTION: _python_check_occluded_packages +# @INTERNAL +# @DESCRIPTION: +# Check if the current directory does not contain any incomplete +# package sources that would block installed packages from being used +# (and effectively e.g. make it impossible to load compiled extensions). +_python_check_occluded_packages() { + debug-print-function ${FUNCNAME} "${@}" + + # DO NOT ENABLE THIS unless you're going to check for false + # positives before filing bugs. + [[ ! ${PYTHON_EXPERIMENTAL_QA} ]] && return + + type -P diff &>/dev/null || return + [[ -z ${BUILD_DIR} || ! -d ${BUILD_DIR}/install ]] && return + + local sitedir="${BUILD_DIR}/install$(python_get_sitedir)" + # avoid unnecessarily checking if we are inside install dir + [[ ${sitedir} -ef . ]] && return + + local f fn diff + for f in "${sitedir}"/*/; do + f=${f%/} + fn=${f##*/} + + # skip metadata directories + [[ ${fn} == *.dist-info || ${fn} == *.egg-info ]] && continue + + if [[ -d ${fn} ]]; then + diff=$(diff -dupr -x "__pycache__" "${fn}" "${sitedir}/${fn}") + if [[ -n ${diff} ]]; then + eqawarn "The directory ${fn} occludes package installed for ${EPYTHON}." + echo + echo ">>> Diff:" + echo "${diff}" + echo "<<< End-of-diff" + echo + + if [[ ! ${_PYTHON_WARNED_OCCLUDED_PACKAGES} ]]; then + eqawarn "The complete build log includes diffs." + eqawarn "For more information on occluded packages, please see:" + eqawarn "https://projects.gentoo.org/python/guide/test.html#importerrors-for-c-extensions" + _PYTHON_WARNED_OCCLUDED_PACKAGES=1 + fi + fi + fi + done +} + # @VARIABLE: EPYTEST_DESELECT # @DEFAULT_UNSET # @DESCRIPTION: @@ -1261,6 +1310,7 @@ epytest() { debug-print-function ${FUNCNAME} "${@}" _python_check_EPYTHON + _python_check_occluded_packages local color case ${NOCOLOR} in @@ -1345,6 +1395,7 @@ eunittest() { debug-print-function ${FUNCNAME} "${@}" _python_check_EPYTHON + _python_check_occluded_packages # unittest fails with "no tests" correctly since Python 3.12 local runner=unittest