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 C54BD15803E for ; Sat, 6 Jan 2024 13:45:17 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 60E642BC06F; Sat, 6 Jan 2024 13:44:55 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [IPv6:2001:470:ea4a:1:5054:ff:fec7:86e4]) (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 1CD3A2BC068 for ; Sat, 6 Jan 2024 13:44: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 2/9] install-qa-check.d/60python-site: Add invalid site-packages check Date: Sat, 6 Jan 2024 14:44:39 +0100 Message-ID: <20240106134446.26153-2-mgorny@gentoo.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240106134446.26153-1-mgorny@gentoo.org> References: <20240106134446.26153-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: 9799d44c-f542-4e15-9b7e-5d21b22370d4 X-Archives-Hash: 429e23681182a8d8793481ed9f8b01de Signed-off-by: Michał Górny --- metadata/install-qa-check.d/60python-site | 45 ++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/metadata/install-qa-check.d/60python-site b/metadata/install-qa-check.d/60python-site index 5f812ecd01e1..459509f8a136 100644 --- a/metadata/install-qa-check.d/60python-site +++ b/metadata/install-qa-check.d/60python-site @@ -11,12 +11,21 @@ python_site_check() { local progs=( "${EPREFIX}"/usr/lib/python-exec/*/gpep517 ) ${save} + local forbidden_package_names=( + # NB: setuptools/discovery.py is a good source of ideas + benchmark benchmarks dist doc docs examples scripts tasks + test tests tools util utils + .pytest_cache .hypothesis _trial_temp + ) + local invalid=() local mismatched_timestamp=() local mismatched_data=() local missing=() local stray=() + local stray_packages=() + # Avoid running the check if sufficiently new gpep517 is not installed # yet. It's valid to schedule (for merge order) >=gpep517-8 after # packages which have this check run if they don't use distutils-r1. @@ -24,12 +33,33 @@ python_site_check() { return fi + local f prog for prog in "${progs[@]}"; do local impl=${prog%/*} impl=${impl##*/} # NB: using ${impl}* to catch pypy3.* for pypy3 - [[ -d "${ED}"/usr/lib/${impl}*/site-packages ]] || continue + local sitedir=( "${ED}"/usr/lib/${impl}*/site-packages ) + [[ -d ${sitedir} ]] || continue + + # check for stray files in site-packages + while IFS= read -d $'\0' -r f; do + stray_packages+=( "${f#${ED}}" ) + done < <( + find "${sitedir}" -maxdepth 1 -type f '!' '(' \ + -name '*.egg-info' -o \ + -name '*.pth' -o \ + -name '*.py' -o \ + -name '*.pyi' -o \ + -name "*$(get_modname)" \ + ')' -print0 + ) + # check for forbidden packages + for f in "${forbidden_package_names[@]}"; do + [[ -d ${sitedir}/${f} ]] && stray_packages+=( + "${sitedir#${ED}}/${f}" + ) + done einfo "Verifying compiled files for ${impl}" local kind pyc py @@ -117,6 +147,19 @@ python_site_check() { eqawarn "For more information on bytecode files and related issues, please see:" eqawarn " https://projects.gentoo.org/python/guide/qawarn.html#compiled-bytecode-related-warnings" fi + + if [[ ${stray_packages[@]} ]]; then + eqawarn + eqawarn "QA Notice: The following unexpected files/directories were found" + eqawarn "top-level in the site-packages directory:" + eqawarn + eqatag -v python-site.stray "${stray_packages[@]}" + eqawarn + eqawarn "This is most likely a bug in the build system. More information" + eqawarn "can be found in the Python Guide:" + eqawarn "https://projects.gentoo.org/python/guide/qawarn.html#stray-top-level-files-in-site-packages" + die "Failing install because of stray top-level files in site-packages" + fi } python_site_check -- 2.43.0