Introduce a distutils_write_namespace helper that can be used to
temporarily write a namespace __init__.py as needed to run tests
when legacy dev-python/namespace-* packages are installed.
Signed-off-by: Michał Górny <
mgorny@gentoo.org>
---
eclass/distutils-r1.eclass | 41 ++++++++++++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
index f9cb41aa3d42..ccdf0e025758 100644
--- a/eclass/distutils-r1.eclass
+++ b/eclass/distutils-r1.eclass
@@ -750,6 +750,42 @@ distutils_install_for_testing() {
esetup.py install "${add_args[@]}" "${@}"
}
+# @FUNCTION: distutils_write_namespace
+# @USAGE: <namespace>...
+# @DESCRIPTION:
+# Write the __init__.py file for the requested namespace into PEP517
+# install tree, in order to fix running tests when legacy namespace
+# packages are installed (dev-python/namespace-*).
+#
+# This function must only be used in python_test(). The created file
+# will automatically be removed upon leaving the test phase. +distutils_write_namespace() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ if [[ ! ${DISTUTILS_USE_PEP517} ]]; then
+ die "${FUNCNAME} is available only in PEP517 mode"
+ fi
+ if [[ ${EBUILD_PHAS