1 |
Add a check for *-nspkg.pth files indicating implicit setuptools |
2 |
namespace hack. While they kept namespaces somewhat working without |
3 |
requiring explicit support in ebuilds, they were unreliable. They |
4 |
frequently required additional hacks (distutils_install_for_testing) to |
5 |
get the tests working, and they have proven even more broken for Python |
6 |
3.5+. |
7 |
|
8 |
For this reason, those files were deprecated in favor of proper, |
9 |
explicit namespace support. If they are found to exist, the developer |
10 |
should ensure to remove them to avoid issues. |
11 |
--- |
12 |
eclass/distutils-r1.eclass | 29 +++++++++++++++++++++++++++++ |
13 |
1 file changed, 29 insertions(+) |
14 |
|
15 |
**REVIEW NOTE** |
16 |
|
17 |
The wiki documentation update is not yet in place for the new policy |
18 |
is not yet in place. In fact, it's not even guaranteed that the policy |
19 |
will actually be approved. The discussion is taking place here: |
20 |
|
21 |
https://archives.gentoo.org/gentoo-python/message/d74af64a795cb776ac7b4f285963072d |
22 |
|
23 |
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass |
24 |
index 3be67bbf2a21..5df7234332d3 100644 |
25 |
--- a/eclass/distutils-r1.eclass |
26 |
+++ b/eclass/distutils-r1.eclass |
27 |
@@ -789,6 +789,33 @@ distutils-r1_src_test() { |
28 |
fi |
29 |
} |
30 |
|
31 |
+# @FUNCTION: _distutils-r1_check_namespace_pth |
32 |
+# @INTERNAL |
33 |
+# @DESCRIPTION: |
34 |
+# Check if any *-nspkg.pth files were installed (by setuptools) |
35 |
+# and warn about the policy non-conformance if they were. |
36 |
+_distutils-r1_check_namespace_pth() { |
37 |
+ local f pth=() |
38 |
+ |
39 |
+ while IFS= read -r -d '' f; do |
40 |
+ pth+=( "${f}" ) |
41 |
+ done < <(find "${ED}" -name '*-nspkg.pth' -print0) |
42 |
+ |
43 |
+ if [[ ${pth[@]} ]]; then |
44 |
+ ewarn "The following *-nspkg.pth files were found installed:" |
45 |
+ ewarn |
46 |
+ for f in "${pth[@]}"; do |
47 |
+ ewarn " ${f#${ED%/}}" |
48 |
+ done |
49 |
+ ewarn |
50 |
+ ewarn "The presence of those files may break namespaces in Python 3.5+. Please" |
51 |
+ ewarn "read our documentation on reliable handling of namespaces and update" |
52 |
+ ewarn "the ebuild accordingly:" |
53 |
+ ewarn |
54 |
+ ewarn " https://wiki.gentoo.org/wiki/Project:Python/Namespace_packages" |
55 |
+ fi |
56 |
+} |
57 |
+ |
58 |
distutils-r1_src_install() { |
59 |
debug-print-function ${FUNCNAME} "${@}" |
60 |
|
61 |
@@ -812,6 +839,8 @@ distutils-r1_src_install() { |
62 |
|
63 |
"${cmd}" "QA: python_install_all() didn't call distutils-r1_python_install_all" |
64 |
fi |
65 |
+ |
66 |
+ _distutils-r1_check_namespace_pth |
67 |
} |
68 |
|
69 |
# -- distutils.eclass functions -- |
70 |
-- |
71 |
2.13.0.rc1 |