Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o, Jason Zaman <perfinion@g.o>, NP-Hardass <NP-Hardass@g.o>
Subject: Re: [gentoo-dev] [RFC] New eclass: mate
Date: Wed, 15 Jun 2016 07:39:30
Message-Id: 8101155A-1368-45BE-BA0F-6B0AA67750D4@gentoo.org
In Reply to: Re: [gentoo-dev] [RFC] New eclass: mate by Jason Zaman
1 Dnia 15 czerwca 2016 06:18:31 CEST, Jason Zaman <perfinion@g.o> napisał(a):
2 >On Fri, Jun 10, 2016 at 12:52:34PM -0400, NP-Hardass wrote:
3 >> On 06/09/2016 11:54 PM, Jason Zaman wrote:
4 >> > On Thu, Jun 09, 2016 at 08:19:43AM -0400, NP-Hardass wrote:
5 >> >> # @FUNCTION: python_cond_func_wrap
6 >> >> # @DESCRIPTION: Wraps a function for conditional python use, to
7 >run for each
8 >> >> # python implementation in the build directory.
9 >> >> python_cond_func_wrap() {
10 >> >> if use python; then
11 >> >> python_foreach_impl run_in_build_dir "$@"
12 >> >> else
13 >> >> $@
14 >> >> fi
15 >> >> }
16 >> >
17 >> > I dont see where you inherited the python eclasses? You also
18 >probably
19 >> > need to use use_if_iuse (from eutils.eclass) instead since it seems
20 >like
21 >> > python might not be in all the ebuilds. Afaik, you're not allowed
22 >to
23 >> > call use foo if foo is not in IUSE already
24 >> I forgot to include a comment in the ebuild, but the intention was
25 >that
26 >> the eclass would not inherit python, by design, those wanting to use
27 >> that should inherit python themselves. Although, if I should check
28 >that
29 >> explicitly, I am unaware of how to do so, and would appreciate advice
30 >> from someone, if it is possible. I am aware of INHERITED, but the PMS
31 >> says it shouldn't be exported to ebuilds, so I'm unsure if/how it
32 >could
33 >> be used.
34 >>
35 >> My hope was that since this is used several times (though, not too
36 >> many), that I could move this logic into the eclass, but if it would
37 >be
38 >> more appropriate to just keep that in each of those ebuilds, I can do
39 >> that too.
40 >
41 >Yeah sounds like keeping this in the eclass is right. Moving duplicated
42 >code into the ebuilds would be a waste. You are defining the API so
43 >requiring the ebuild to inherit itself is completely okay. I would add
44 >a
45 >little more to the doc above to make it super obvious tho.
46 >
47 >I don't know how to check if the python eclasses specifically are
48 >inherited. I think "python" being in IUSE would be sufficient to check
49 >tho. so all you'd need to do is inherit eutils and replace the "if use
50 >python" with "if use_if_iuse python".
51 >
52 >If you *really* wanted to check you could perhaps do
53 >if [[ $(type python_foreach_impl) == function ]]. Seems overkill and I
54 >wouldn't bother. Having python in iuse is probably enough of a sanity
55 >check.
56
57 You can check for the include guards. This is how python-r1 eclasses detect one another (in order to prevent inheriting multiple of them).
58
59 However, note that all fancy checks are allowed in phase scope only, and not in global scope.
60
61 >
62 >-- Jason
63
64
65 --
66 Best regards,
67 Michał Górny (by phone)