diff options
author | Michał Górny <mgorny@gentoo.org> | 2023-02-04 18:56:13 +0100 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2023-02-07 15:24:39 +0100 |
commit | 81b315aa895f4224958bbc4f9abe9c655205f60d (patch) | |
tree | 0efb05f8a4d08fbabf37348fd61b925cb205531f /eclass/distutils-r1.eclass | |
parent | dev-python/ruamel-std-pathlib: Bump to 0.12.0 (diff) | |
download | gentoo-81b315aa895f4224958bbc4f9abe9c655205f60d.tar.gz gentoo-81b315aa895f4224958bbc4f9abe9c655205f60d.tar.bz2 gentoo-81b315aa895f4224958bbc4f9abe9c655205f60d.zip |
distutils-r1.eclass: Report stray top-level files in site-packages
In addition to checking for known-bad package names, detect stray
files installed into top-level site-packages directory. This is
primarily meant to cover the common mistake in using `include`
in Poetry-built packages.
Closes: https://bugs.gentoo.org/893172
Closes: https://github.com/gentoo/gentoo/pull/29425
Signed-off-by: Michał Górny <mgorny@gentoo.org>
Diffstat (limited to 'eclass/distutils-r1.eclass')
-rw-r--r-- | eclass/distutils-r1.eclass | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass index 8896768d3ce9..a6be88ad858d 100644 --- a/eclass/distutils-r1.eclass +++ b/eclass/distutils-r1.eclass @@ -171,7 +171,7 @@ esac if [[ ! ${_DISTUTILS_R1} ]]; then -inherit multibuild multiprocessing ninja-utils toolchain-funcs +inherit multibuild multilib multiprocessing ninja-utils toolchain-funcs if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then inherit python-r1 @@ -1985,12 +1985,34 @@ _distutils-r1_post_python_install() { examples test tests .pytest_cache .hypothesis _trial_temp ) + local strays=() local p + mapfile -d $'\0' -t strays < <( + find "${sitedir}" -maxdepth 1 -type f '!' '(' \ + -name '*.egg-info' -o \ + -name '*.pth' -o \ + -name '*.py' -o \ + -name '*.pyi' -o \ + -name "*$(get_modname)" \ + ')' -print0 + ) for p in "${forbidden_package_names[@]}"; do - if [[ -d ${sitedir}/${p} ]]; then - die "Package installs '${p}' package which is forbidden and likely a bug in the build system." - fi + [[ -d ${sitedir}/${p} ]] && strays+=( "${sitedir}/${p}" ) done + + if [[ -n ${strays[@]} ]]; then + eerror "The following unexpected files/directories were found top-level" + eerror "in the site-packages directory:" + eerror + for p in "${strays[@]}"; do + eerror " ${p#${ED}}" + done + eerror + eerror "This is most likely a bug in the build system. More information" + eerror "can be found in the Python Guide:" + eerror "https://projects.gentoo.org/python/guide/qawarn.html#stray-top-level-files-in-site-packages" + die "Failing install because of stray top-level files in site-packages" + fi fi } |