On Fri, Jun 10, 2016 at 12:52:34PM -0400, NP-Hardass wrote:
> On 06/09/2016 11:54 PM, Jason Zaman wrote:
> > On Thu, Jun 09, 2016 at 08:19:43AM -0400, NP-Hardass wrote:
> >> # @FUNCTION: python_cond_func_wrap
> >> # @DESCRIPTION: Wraps a function for conditional python use, to run for
> >> each
> >> # python implementation in the build directory.
> >> python_cond_func_wrap() {
> >> if use python; then
> >> python_foreach_impl run_in_build_dir "$@"
> >> else
> >> $@
> >> fi
> >> }
> >
> > I dont see where you inherited the python eclasses? You also probably
> > need to use use_if_iuse (from eutils.eclass) instead since it seems like
> > python might not be in all the ebuilds. Afaik, you're not allowed to
> > call use foo if foo is not in IUSE already
> I forgot to include a comment in the ebuild, but the intention was that
> the eclass would not inherit python, by design, those wanting to use
> that should inherit python themselves. Although, if I should check that
> explicitly, I am unaware of how to do so, and would appreciate advice
> from someone, if it is possible. I am aware of INHERITED, but the PMS
> says it shouldn't be exported to ebuilds, so I'm unsure if/how it could
> be used.
>
> My hope was that since this is used several times (though, not too
> many), that I could move this logic into the eclass, but if it would be
> more appropriate to just keep that in each of those ebuilds, I can do
> that too.
Yeah sounds like keeping this in the eclass is right. Moving duplicated
code into the ebuilds would be a waste. You are defining the API so
requiring the ebuild to inherit itself is completely okay. I would add a
little more to the doc above to make it super obvious tho.
I don't know how to check if the python eclasses specifically are
inherited. I think "python" being in IUSE would be sufficient to check
tho. so all you'd need to do is inherit eutils and replace the "if use
python" with "if use_if_iuse python".
If you *really* wanted to check you could perhaps do
if [[ $(type python_foreach_impl) == function ]]. Seems overkill and I
wouldn't bother. Having python in iuse is probably enough of a sanity
check.
-- Jason