summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2024-01-05 15:35:10 +0100
committerMichał Górny <mgorny@gentoo.org>2024-01-08 15:48:17 +0100
commitc80d77f0c503a4e01f7792afb8fcde30164916fe (patch)
tree4ca94a27c704e081f1bb01d7a4406343cfcebaf9
parentinstall-qa-check.d: Generalize 60python-{pyc → site} (diff)
downloadgentoo-c80d77f0c503a4e01f7792afb8fcde30164916fe.tar.gz
gentoo-c80d77f0c503a4e01f7792afb8fcde30164916fe.tar.bz2
gentoo-c80d77f0c503a4e01f7792afb8fcde30164916fe.zip
install-qa-check.d/60python-site: Add invalid site-packages check
Signed-off-by: Michał Górny <mgorny@gentoo.org>
-rw-r--r--metadata/install-qa-check.d/60python-site47
1 files changed, 46 insertions, 1 deletions
diff --git a/metadata/install-qa-check.d/60python-site b/metadata/install-qa-check.d/60python-site
index 5f812ecd01e1..eb59ad5cac26 100644
--- a/metadata/install-qa-check.d/60python-site
+++ b/metadata/install-qa-check.d/60python-site
@@ -11,12 +11,21 @@ python_site_check() {
local progs=( "${EPREFIX}"/usr/lib/python-exec/*/gpep517 )
${save}
+ local forbidden_package_names=(
+ # NB: setuptools/discovery.py is a good source of ideas
+ benchmark benchmarks dist doc docs examples scripts tasks
+ test tests tools util utils
+ .pytest_cache .hypothesis _trial_temp
+ )
+
local invalid=()
local mismatched_timestamp=()
local mismatched_data=()
local missing=()
local stray=()
+ local stray_packages=()
+
# Avoid running the check if sufficiently new gpep517 is not installed
# yet. It's valid to schedule (for merge order) >=gpep517-8 after
# packages which have this check run if they don't use distutils-r1.
@@ -24,12 +33,33 @@ python_site_check() {
return
fi
+ local f prog
for prog in "${progs[@]}"; do
local impl=${prog%/*}
impl=${impl##*/}
# NB: using ${impl}* to catch pypy3.* for pypy3
- [[ -d "${ED}"/usr/lib/${impl}*/site-packages ]] || continue
+ local sitedir=( "${ED}"/usr/lib/${impl}*/site-packages )
+ [[ -d ${sitedir} ]] || continue
+
+ # check for stray files in site-packages
+ while IFS= read -d $'\0' -r f; do
+ stray_packages+=( "${f#${ED}}" )
+ done < <(
+ find "${sitedir}" -maxdepth 1 -type f '!' '(' \
+ -name '*.egg-info' -o \
+ -name '*.pth' -o \
+ -name '*.py' -o \
+ -name '*.pyi' -o \
+ -name "*$(get_modname)" \
+ ')' -print0
+ )
+ # check for forbidden packages
+ for f in "${forbidden_package_names[@]}"; do
+ [[ -d ${sitedir}/${f} ]] && stray_packages+=(
+ "${sitedir#${ED}}/${f}"
+ )
+ done
einfo "Verifying compiled files for ${impl}"
local kind pyc py
@@ -117,6 +147,21 @@ python_site_check() {
eqawarn "For more information on bytecode files and related issues, please see:"
eqawarn " https://projects.gentoo.org/python/guide/qawarn.html#compiled-bytecode-related-warnings"
fi
+
+ if [[ ${stray_packages[@]} ]]; then
+ eqawarn
+ eqawarn "QA Notice: The following unexpected files/directories were found"
+ eqawarn "top-level in the site-packages directory:"
+ eqawarn
+ eqatag -v python-site.stray "${stray_packages[@]}"
+ eqawarn
+ eqawarn "This is most likely a bug in the build system. More information"
+ eqawarn "can be found in the Python Guide:"
+ eqawarn "https://projects.gentoo.org/python/guide/qawarn.html#stray-top-level-files-in-site-packages"
+ # TODO: make this fatal once we fix the existing issues, and remove
+ # the previous version from distutils-r1
+ #die "Failing install because of stray top-level files in site-packages"
+ fi
}
python_site_check