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 8/9] install-qa-check.d/60python-site: Check for out-of-sitepkg install
Date: Sat,  6 Jan 2024 14:44:45 +0100	[thread overview]
Message-ID: <20240106134446.26153-8-mgorny@gentoo.org> (raw)
In-Reply-To: <20240106134446.26153-1-mgorny@gentoo.org>

Signed-off-by: Michał Górny <mgorny@gentoo.org>
---
 metadata/install-qa-check.d/60python-site | 28 ++++++++++++++++++++++-
 1 file changed, 27 insertions(+), 1 deletion(-)

diff --git a/metadata/install-qa-check.d/60python-site b/metadata/install-qa-check.d/60python-site
index 26f26d6cc527..cb31c7f98e08 100644
--- a/metadata/install-qa-check.d/60python-site
+++ b/metadata/install-qa-check.d/60python-site
@@ -31,6 +31,7 @@ python_site_check() {
 	local stray=()
 
 	local bad_versions=()
+	local outside_site=()
 	local stray_packages=()
 
 	# Avoid running the check if sufficiently new gpep517 is not installed
@@ -46,7 +47,24 @@ python_site_check() {
 		impl=${impl##*/}
 
 		# NB: using ${impl}* to catch pypy3.* for pypy3
-		local sitedir=( "${ED}"/usr/lib/${impl}*/site-packages )
+		local pydir=( "${ED}"/usr/lib/${impl}* )
+		[[ -d ${pydir} ]] || continue
+
+		# check for packages installing outside site-packages
+		case ${CATEGORY}/${PN} in
+			dev-lang/python|dev-python/pypy*)
+				;;
+			*)
+				while IFS= read -d $'\0' -r f; do
+					outside_site+=( "${f}" )
+				done < <(
+					find "${pydir}" -mindepth 1 -maxdepth 1 \
+						'!' -name site-packages -print0
+				)
+				;;
+		esac
+
+		local sitedir=( "${pydir}"/site-packages )
 		[[ -d ${sitedir} ]] || continue
 
 		# check for bad package versions
@@ -195,6 +213,14 @@ python_site_check() {
 		eqawarn
 		eqatag -v python-site.libdir "${bad_libdirs[@]#${ED}}"
 	fi
+
+	if [[ ${outside_site[@]} ]]; then
+		eqawarn
+		eqawarn "QA Notice: Files found installed directly into Python stdlib,"
+		eqawarn "instead of site-packages (use \$(python_get_sitedir)):"
+		eqawarn
+		eqatag -v python-site.stdlib "${outside_site[@]}"
+	fi
 }
 
 python_site_check
-- 
2.43.0



  parent reply	other threads:[~2024-01-06 13:46 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-06 13:44 [gentoo-dev] [PATCH 1/9] install-qa-check.d: Generalize 60python-{pyc → site} Michał Górny
2024-01-06 13:44 ` [gentoo-dev] [PATCH 2/9] install-qa-check.d/60python-site: Add invalid site-packages check Michał Górny
2024-01-06 13:44 ` [gentoo-dev] [PATCH 3/9] distutils-r1.eclass: Stray file check moved to install-qa-check.d Michał Górny
2024-01-06 13:44 ` [gentoo-dev] [PATCH 4/9] install-qa-check.d/60python-site: Add bad version check Michał Górny
2024-01-06 13:44 ` [gentoo-dev] [PATCH 5/9] install-qa-check.d/60python-site: Forbid lib & usr package names Michał Górny
2024-01-06 13:44 ` [gentoo-dev] [PATCH 6/9] install-qa-check.d/60python-site: Add check for wrong libdir Michał Górny
2024-01-06 13:44 ` [gentoo-dev] [PATCH 7/9] install-qa-check.d/60python-site: Check for UNKNOWN package name Michał Górny
2024-01-06 13:44 ` Michał Górny [this message]
2024-01-06 13:44 ` [gentoo-dev] [PATCH 9/9] install-qa-check.d/60python-site: allow site-packages/README.txt 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=20240106134446.26153-8-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