• [gentoo-dev] [PATCH] install-qa-check.d: Add namespace package check to

    From =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?@21:1/5 to All on Thu May 29 08:20:01 2025
    Add an explicit check for namespace packages (both pkg_resources
    and pkgutil) 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.

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

    diff --git a/metadata/install-qa-check.d/60python-site b/metadata/install-qa-check.d/60python-site
    index 49d4b3a1a830..933c5368b930 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\|pkgutil.*extend_path" "${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
    whil