public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
From: Marien Zwart <marienz@gentoo.org>
To: "Michał Górny" <mgorny@gentoo.org>
Cc: Gentoo Developer Mailing List <gentoo-dev@lists.gentoo.org>,
	python@gentoo.org
Subject: [gentoo-dev] Re: [New eclass] twisted-r1.eclass
Date: Sun, 4 Aug 2013 15:15:12 +1000	[thread overview]
Message-ID: <CAEWfL_StpcffuAweZH66xhksj+L=xTOokjoMaD+AYf+rf6sO=g@mail.gmail.com> (raw)
In-Reply-To: <20130803171303.18911eba@gentoo.org>

On Sun, Aug 4, 2013 at 1:13 AM, Michał Górny <mgorny@gentoo.org> wrote:
> We've been working with yac for a while to get the old twisted.eclass
> converted to be compliant with distutils-r1 both in design
> and in spirit. This is the first version we'd like to submit for review.

Thanks for doing this. If memory serves (and cvs log says it does) I'm
to blame for the first version of this eclass so perhaps I should
review this one :) twisted.eclass changed quite a bit since I last
looked at it, though.

I've reviewed the "One more bit of optimization" version.

> 1. The eclass aims to be less conditional than the old one. Especially
> we've dropped all the ${CATEGORY}/${PN} checks. The code still sets all
> the funny defaults for Twisted suite but those aren't incremental
> and can easily be overrode in ebuilds. And in most cases, they simple
> are (SRC_URI, LICENSE).

The original version just set those unconditionally, the conditionals
I think you're referring to were added by Arfrever in revision 1.8.
It's not clear to me why. Does someone on this list remember?

> 2. The eclass comes with a pure bash-3.2 CamelCase converter
> for changing PNs like 'twisted-foo' into 'TwistedFoo'. The relevant
> code can be moved to eutils as portable replacements for bash-4 ${foo^}
> and friends.

That was considered when the original was committed but rejected as
getting too messy. Two questions: have you tested this contraption
with the oldest version of bash we still care about, and have you
considered making it take the input as an argument and echoing the
result (making it work the way versionator.eclass functions do)? If
you want this to be usable as a portable utility function you'd have
to write it that way, might as well do that from the start.

I'm only ok with this code because we'll eventually end up requiring
bash 4 at which point this can be written sanely.

> 3. The eclass provides a reusable twisted-r1_python_test and sets it as
> default python_test. If someone needs to override it, he can still call
> it using the former name.

Kind of a shame EXPORT_FUNCTIONS only works on actual phase functions.
The rm -rf in there is slightly hacky: its target will legitimately
not exist if this is the initial install or if we're not in a
twisted-* package (in which case the package should probably not be
hitting this function, but it will if not overridden). There's
potential for confusion there if an upgrade drops or renames a
twisted/plugins/twisted_blah.py file, but that seems like enough of an
edge case it's not worth worrying about.

I was going to recommend adding variables that control what gets
copied and removed, but I can't think of any current users of such
variables. So it's probably not worth the hassle.

If I read this right it'll break if distutils_install_for_testing ever
changes its mind on where to install (and its docstring says to use
TEST_DIR, not which path that'll be). So I'd add a check for
${TEST_DIR}/lib being equal to $libdir after the call to
distutils_install_for_testing, and print a noisy QA message about
updating the eclass if they're different.

> 4. Cache updating hack is based off twisted.eclass. Sadly, it's not
> something we can do without postrm/postinst. Similarly to the old
> eclass, TWISTED_PLUGINS needs to list the plugin locations. Since most
> ebuilds install to twisted.plugins, it defaults to that. If an ebuild
> does not install plugins at all, it needs to set empty TWISTED_PLUGINS.

If I read that right you can just __import__(module), you don't need
__import__(module, globals()). Also, maybe do the loop over plugin
locations in bash. I think if you do that you don't need __import__
and sys.modules anymore, you can just generate "import $module" and
"list(getPlugins(IPlugin, $module))".

I wouldn't worry too much about using pkg_post* for this. It's what
they're there for (twisted's isn't the only plugin system with a file
like this, see for example gdk-pixbuf).

It seems that if TWISTED_PLUGINS is set to the empty array, "[[
${TWISTED_PLUGINS[@]} ]] || TWISTED_PLUGINS=( twisted.plugins )" will
set it to twisted.plugins. Is that intentional? It's not necessarily a
problem (you can just set TWISTED_PLUGINS back to the empty array
after the inherit) but it's a bit confusing and I don't think it's
what you intended (why bother with that conditional at all?)

I was going to claim importing from twisted.plugin should never fail,
but then I realized dev-python/twisted might want to use these
functions too.

I might add a comment to the functions operating on that array to
remind people it might be the empty array. It wasn't immediately
obvious to me upon reading the code it'd safely do nothing (today I
learned "rm -f" (with no further arguments) successfully does nothing,
while "rm" (with no arguments) fails because of a missing operand).
-- 

Marien Zwart (marienz)


  parent reply	other threads:[~2013-08-04  5:15 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-03 15:13 [gentoo-dev] [New eclass] twisted-r1.eclass Michał Górny
2013-08-03 15:54 ` Ulrich Mueller
2013-08-03 18:29   ` Michał Górny
2013-08-03 19:37     ` Ulrich Mueller
2013-08-03 19:42       ` Michał Górny
2013-08-03 19:37     ` Alex Xu
2013-08-03 19:47       ` Alex Xu
2013-08-03 19:49       ` Michał Górny
2013-08-03 21:57 ` Michał Górny
2013-08-03 22:28 ` Michał Górny
2013-08-04  5:15 ` Marien Zwart [this message]
2013-08-04  7:34   ` [gentoo-dev] " Michał Górny
2013-08-04 12:37 ` [gentoo-dev] " Michał Górny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAEWfL_StpcffuAweZH66xhksj+L=xTOokjoMaD+AYf+rf6sO=g@mail.gmail.com' \
    --to=marienz@gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    --cc=mgorny@gentoo.org \
    --cc=python@gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox