summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2017-05-05 23:08:37 +0200
committerMichał Górny <mgorny@gentoo.org>2017-05-16 19:11:29 +0200
commit457c73f83753c32d8955137603133abe03fc3533 (patch)
tree3a7c40a0991e38cf15f657f2a8c9e1cb8afba5a4 /eclass/distutils-r1.eclass
parentwww-client/chromium: Use eninja from ninja-utils (diff)
downloadgentoo-457c73f83753c32d8955137603133abe03fc3533.tar.gz
gentoo-457c73f83753c32d8955137603133abe03fc3533.tar.bz2
gentoo-457c73f83753c32d8955137603133abe03fc3533.zip
distutils-r1.eclass: Warn if *-nspkg.pth files are installed
Add a check for *-nspkg.pth files indicating implicit setuptools namespace hack. While they kept namespaces somewhat working without requiring explicit support in ebuilds, they were unreliable. They frequently required additional hacks (distutils_install_for_testing) to get the tests working, and they have proven even more broken for Python 3.5+. For this reason, those files were deprecated in favor of proper, explicit namespace support. If they are found to exist, the developer should ensure to remove them to avoid issues.
Diffstat (limited to 'eclass/distutils-r1.eclass')
-rw-r--r--eclass/distutils-r1.eclass29
1 files changed, 29 insertions, 0 deletions
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index 3be67bbf2a21..5df7234332d3 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -789,6 +789,33 @@ distutils-r1_src_test() {
fi
}
+# @FUNCTION: _distutils-r1_check_namespace_pth
+# @INTERNAL
+# @DESCRIPTION:
+# Check if any *-nspkg.pth files were installed (by setuptools)
+# and warn about the policy non-conformance if they were.
+_distutils-r1_check_namespace_pth() {
+ local f pth=()
+
+ while IFS= read -r -d '' f; do
+ pth+=( "${f}" )
+ done < <(find "${ED}" -name '*-nspkg.pth' -print0)
+
+ if [[ ${pth[@]} ]]; then
+ ewarn "The following *-nspkg.pth files were found installed:"
+ ewarn
+ for f in "${pth[@]}"; do
+ ewarn " ${f#${ED%/}}"
+ done
+ ewarn
+ ewarn "The presence of those files may break namespaces in Python 3.5+. Please"
+ ewarn "read our documentation on reliable handling of namespaces and update"
+ ewarn "the ebuild accordingly:"
+ ewarn
+ ewarn " https://wiki.gentoo.org/wiki/Project:Python/Namespace_packages"
+ fi
+}
+
distutils-r1_src_install() {
debug-print-function ${FUNCNAME} "${@}"
@@ -812,6 +839,8 @@ distutils-r1_src_install() {
"${cmd}" "QA: python_install_all() didn't call distutils-r1_python_install_all"
fi
+
+ _distutils-r1_check_namespace_pth
}
# -- distutils.eclass functions --