Gentoo Archives: gentoo-dev

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

Attachments

File name MIME type
signature.asc application/pgp-signature