commit: 182ab2f269ec6d7dddfbf0b6013d7d0fbdad1bc9 Author: Michał Górny <mgorny <AT> gentoo <DOT> org> AuthorDate: Thu May 29 06:14:55 2025 +0000 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> CommitDate: Sun Jun 1 12:35:25 2025 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=182ab2f2
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 <AT> 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 <AT> gentoo.org> metadata/install-qa-check.d/60python-site | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/metadata/install-qa-check.d/60python-site b/metadata/install-qa-check.d/60python-site index 49d4b3a1a830..4dd8d636e7cc 100644 --- a/metadata/install-qa-check.d/60python-site +++ b/metadata/install-qa-check.d/60python-site @@ -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,"
