Skip to content

Clarify about plugins importing other plugins

I have in my head that we discourage importing plugins from other plugins.

It does appear to be possible currently, e.g. the following appears to work:

from . import dpkg_build

# Element implementation for the 'my_dpkg_build' kind.
class MyDpkgElement(dpkg_build.DpkgElement):
      pass

# Plugin entry point
def setup():
    return MyDpkgElement

There is another way people might try this, which is to do from buildstream.plugins.elements.dpkg_build import DpkgElement. That produces a confusing error, due to the way pluginbase creates unique namespaces for plugin modules:

...
  File "/home/sam/.local/lib/python3.5/site-packages/pluginbase-0.5-py3.5.egg/pluginbase.py", line 410, in plugin_import
    fromlist, level)
  File "/home/shared/src/buildstream/buildstream/plugins/elements/mydpkgelement.py", line 1, in <module>
    from buildstream.plugins.elements.dpkg_build import DpkgElement
  File "/home/sam/.local/lib/python3.5/site-packages/pluginbase-0.5-py3.5.egg/pluginbase.py", line 410, in plugin_import
    fromlist, level)
ImportError: No module named 'pluginbase._internalspace._sp27c7c99949c6a90425f3e60eb6eb621f.elements'

We need to update the docs to either say "here is how you do this", or "don't do this".

ML discussion: https://mail.gnome.org/archives/buildstream-list/2017-August/msg00001.html

Edited by Sam Thursfield
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information