[Distutils] Changing the "install hooks" mechanism for PEP 426

PJ Eby pje at telecommunity.com
Wed Aug 14 20:00:35 CEST 2013

On Wed, Aug 14, 2013 at 11:36 AM, Nick Coghlan <ncoghlan at gmail.com> wrote:
> * group - name of the export group to hook
> * preupdate - export to call prior to installing/updating/removing a
> distribution that exports this export group
> * postupdate - export to call after installing/updating/removing a
> distribution that exports this export group
> * refresh - export to call to resynchronise any caches with the system
> state. This will be invoked for every distribution on the system that
> exports this export group any time the distribution defining the
> export hook is itself installed or upgraded

I've reread your post a few times and I'm not sure I understand it.
Let me try and spell out a scenario to see if I've got it:

* Distribution A defines a refresh hook for group 'foo.bar' -- but
doesn't export anything in that group
* Distribution B defines an *export* (fka "entry point") -- any export
-- in export group 'foo.bar' -- but doesn't define any hooks
* Distribution A's refresh hook will be notified when B is installed,
updated, or removed

Is that what this is for?

If so, my confusion is probably because of overloading of the term
"export" in this context; among other things, it's unclear whether
this is a separate data structure from exports themselves...  and if
so, why?

If I were doing something like this in the existing entry point
system, I'd do something like:

  foo.bar = my.hook.module:refresh

i.e., just list the hooks in an export group, using the export name to
designate what export group is being monitored.  This approach
leverages the fact that exports already need to be indexed, so why
create a whole new sort of metadata just for the hooks?

(But of course if I have misunderstood what you're trying to do in the
first place, this and my other thoughts may be moot.)

(Oh, and btw, if a distribution has hooks for itself, then how are you
going to invoke two different versions of the code?  Rollback
sys.modules and reload?  Spawn another process?)

More information about the Distutils-SIG mailing list