Add a QA check for Python extensions that were compiled for the wrong implementation. This is particularly a case when build is not properly isolated and extensions built for earlier Python versions end up being included in the subsequent installs.
Signed-off-by: Michał Górny <mgo...@gentoo.org> --- metadata/install-qa-check.d/60python-site | 26 +++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/metadata/install-qa-check.d/60python-site b/metadata/install-qa-check.d/60python-site index cd58fa3a5937..f0c2c14cc935 100644 --- a/metadata/install-qa-check.d/60python-site +++ b/metadata/install-qa-check.d/60python-site @@ -34,6 +34,7 @@ python_site_check() { local eggs=() local outside_site=() local stray_packages=() + local wrong_ext=() # Avoid running the check if sufficiently new gpep517 is not installed # yet. It's valid to schedule (for merge order) >=gpep517-8 after @@ -104,6 +105,7 @@ python_site_check() { -name 'README.txt' \ ')' -print0 ) + # check for forbidden packages for f in "${forbidden_package_names[@]}"; do [[ -d ${sitedir}/${f} ]] && stray_packages+=( @@ -111,6 +113,22 @@ python_site_check() { ) done + # check for extensions compiled for wrong implementations + local ext_suffix=$( + "${impl}" - <<-EOF + import sysconfig + print(sysconfig.get_config_var("EXT_SUFFIX")) + EOF + ) + while IFS= read -d $'\0' -r f; do + wrong_ext+=( "${f#${ED}}" ) + done < <( + find "${sitedir}" '(' \ + -name "*.pypy*$(get_modname)" -o \ + -name "*.cpython*$(get_modname)" \ + ')' -a '!' -name "*${ext_suffix}" -print0 + ) + einfo "Verifying compiled files for ${impl}" local kind pyc py while IFS=: read -r kind pyc py extra; do @@ -244,6 +262,14 @@ python_site_check() { eqawarn eqatag -v python-site.stdlib "${outside_site[@]}" fi + + if [[ ${wrong_ext[@]} ]]; then + eqawarn + eqawarn "QA Notice: Extensions found compiled for the wrong Python version" + eqawarn "(likely broken build isolation):" + eqawarn + eqatag -v python-site.wrong-ext "${wrong_ext[@]}" + fi } python_site_check