Re: Implementing a plug-in mechanism

2023-03-16 Thread Loris Bennett
Simon Ward writes: > On Thu, Mar 16, 2023 at 07:45:18AM +1300, dn via Python-list wrote: >> There is a PyPi library called pluggy (not used it). I've used >> informal approaches using an ABC as a framework/reminder (see >> @George's response). > > typing.Protocol is also useful here as the plugin

Re: Implementing a plug-in mechanism

2023-03-16 Thread Simon Ward
On Thu, Mar 16, 2023 at 07:45:18AM +1300, dn via Python-list wrote: There is a PyPi library called pluggy (not used it). I've used informal approaches using an ABC as a framework/reminder (see @George's response). typing.Protocol is also useful here as the plugin interface can be defined sepa

Re: Implementing a plug-in mechanism

2023-03-15 Thread Thomas Passin
On 3/15/2023 6:06 PM, Weatherby,Gerard wrote: I do something similar to Thomas. (Also MIT licensed). I like objects. I like type hints. Each plugin needs to have check and purpose functions and accepts either PluginSpec (by default) or AddonSpec if it defines addon = True I omitted the check

Re: Implementing a plug-in mechanism

2023-03-15 Thread Weatherby,Gerard
I do something similar to Thomas. (Also MIT licensed). I like objects. I like type hints. Each plugin needs to have check and purpose functions and accepts either PluginSpec (by default) or AddonSpec if it defines addon = True This requires a single-level plugin directory with no extra files in

Re: Implementing a plug-in mechanism

2023-03-15 Thread Thomas Passin
On 3/15/2023 2:45 PM, dn via Python-list wrote: On 16/03/2023 01.47, Loris Bennett wrote: I have written a program which, as part of the non-core functionality, contains a module to generate email.  This is currently very specific to my organisation, so the main program contains    import myorg

Re: Implementing a plug-in mechanism

2023-03-15 Thread dn via Python-list
On 16/03/2023 01.47, Loris Bennett wrote: I have written a program which, as part of the non-core functionality, contains a module to generate email. This is currently very specific to my organisation, so the main program contains import myorg.mailer This module is specific to my organisati

Re: Implementing a plug-in mechanism

2023-03-15 Thread Weatherby,Gerard
Yes, that works, and I’ve used that on a couple of projects. Another alternative is defining an Abstract Base Class, https://docs.python.org/3/library/abc.html, and having an institution-specific implementation passed into your module. From: Python-list on behalf of Loris Bennett Date: Wedne