[Grok-dev] the grok package becoming an "import hub"

Sylvain Viollon sylvain at infrae.com
Wed Feb 16 04:10:58 EST 2011


On Tue, 15 Feb 2011 09:50:29 +0100
Jan-Wijbrand Kolman <janwijbrand at gmail.com> wrote:

  Hello

> On 2/14/11 17:14 PM, Matthias wrote:
> > Am 14.02.2011, 12:39 Uhr, schrieb Jan-Wijbrand Kolman
> > <janwijbrand at gmail.com>:
> >
> Yesterday I had to release grok (the package) 1.5 just because it 
> imports two new names from the newly released grokcore.component. No
> big deal BTW, it just made me think about what the "import
> hub-nature" of grok could look like.
>

  In five.grok, I just do from grokcore.component import *, and __all__
  is defined in both packages using the API interfaces. In five.grok,
  the API interface inherit from the one of grokcore.component.

  Like that, if you add an import or a feature in grokcore.component,
  and it is described in its API interface, it will be exported via
  __all__ in both packages. So I don't need to touch five.grok to get
  the new features of grokcore.component. I was thinking Grok did the
  same, and I think * import with __all__ are the perfect use-case for
  'hub-packages'.

  After if you want to get a more 'magical hub', I am not sure of best
  way of doing it: you could list the packages starting with grokcore
  using pkg_resources, and automatically import names defined in their
  __all__ variable, but some packages might redefined components
  provided by other, so you like to be able to order this import step.

  Regards,

  Sylvain,

-- 
Sylvain Viollon -- Infrae
t +31 10 243 7051 -- http://infrae.com
Hoevestraat 10 3033GC Rotterdam -- The Netherlands


More information about the Grok-dev mailing list