install-qa-check.d: Add namespace package check to 60python-site

Add an explicit check for deprecated pkg_resources namespace packages
 to 60python-site.  The eclass handled the most common
case of installing them via the deprecated `namespace_packages`
setuptools key, but it does not handle packages that worked around
the deprecation warning by installing the file manually, or ebuilds
that did strip `namespace_packages` to silence the setuptools
deprecation warning.

Signed-off-by: Michał Górny <mgorny@gentoo.org>
Part-of: https://github.com/gentoo/gentoo/pull/42318
Closes: https://github.com/gentoo/gentoo/pull/42318
Signed-off-by: Michał Górny <mgorny@gentoo.org>
This commit is contained in:
Michał Górny
2025-05-29 08:14:55 +02:00
parent 820262c4c7
commit 182ab2f269

View File

@@ -38,6 +38,7 @@ python_site_check() {
local bad_versions=()
local eggs=()
local namespace_packages=()
local outside_site=()
local stray_packages=()
local wrong_ext=()
@@ -142,6 +143,16 @@ python_site_check() {
')' -a '!' -name "*${ext_suffix}" -print0
)
# check for namespace packages
while IFS= read -d $'\0' -r f; do
if grep -q "pkg_resources.*declare_namespace" "${f}"
then
namespace_packages+=( "${f}" )
fi
done < <(
find "${sitedir}" -maxdepth 2 -type f -name '__init__.py' -print0
)
einfo "Verifying compiled files for ${impl}"
local kind pyc py
while IFS=: read -r kind pyc py extra; do
@@ -268,6 +279,18 @@ python_site_check() {
eqatag -v python-site.libdir "${bad_libdirs[@]#${ED}}"
fi
if [[ ${namespace_packages[@]} ]]; then
eqawarn
eqawarn "QA Notice: Package installs pkg_resources namespace packages that"
eqawarn "are deprecated. Please either remove __init__.py in favor of PEP 420"
eqawarn "implicit namespace, if possible, or replace it with pkgutil namespace."
eqawarn
eqatag -v python-site.libdir "${namespace_packages[@]#${ED}}"
eqawarn
eqawarn "Please report a bug upstream. See also:"
eqawarn "https://projects.gentoo.org/python/guide/concept.html#namespace-packages"
fi
if [[ ${outside_site[@]} ]]; then
eqawarn
eqawarn "QA Notice: Files found installed directly into Python stdlib,"