summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChandan Singh <chandan@chandansingh.net>2020-01-17 16:41:10 +0000
committerChandan Singh <chandan@chandansingh.net>2020-01-17 16:41:10 +0000
commitef4041faab353a64aca433eec33da7155c6d184b (patch)
treeeea8d8f6c88c31a6b484bea3d13f9a062efe2323
parent9a6c7d76324b70d020a8d34d2feef7f0ba2b5a0b (diff)
parentf7f247a5e7973e0b12772f3b5d9353a1de8c485d (diff)
downloadbuildstream-ef4041faab353a64aca433eec33da7155c6d184b.tar.gz
Merge branch 'chandan/plugin-namespace-fix' into 'master'
Plugins: Update entrypoint group for pip origin See merge request BuildStream/buildstream!1803
-rw-r--r--NEWS4
-rw-r--r--doc/source/sample_plugin/setup.py5
-rw-r--r--src/buildstream/_elementfactory.py1
-rw-r--r--src/buildstream/_plugincontext.py8
-rw-r--r--src/buildstream/_sourcefactory.py7
-rw-r--r--tox.ini2
6 files changed, 19 insertions, 8 deletions
diff --git a/NEWS b/NEWS
index 4dd54c85b..c9d3f0536 100644
--- a/NEWS
+++ b/NEWS
@@ -12,6 +12,10 @@ CLI
API
---
+ o BREAKING CHANGE: The entry point groups used for element and source plugins
+ are now separate. Elements must be defined in `buildstream.plugins.elements`
+ group, and sources in `buildstream.plugins.sources`.
+
o External plugins can now register a `buildstream.tests.source_plugins` entrypoint.
The entry point can have an arbitrary name, but its value should point to a module
containing a `register_sources()` method.
diff --git a/doc/source/sample_plugin/setup.py b/doc/source/sample_plugin/setup.py
index 7ea0e1ef3..4e2e789f9 100644
--- a/doc/source/sample_plugin/setup.py
+++ b/doc/source/sample_plugin/setup.py
@@ -4,12 +4,9 @@ setup(name='BuildStream Autotools',
version="0.1",
description="A better autotools element for BuildStream",
packages=find_packages(),
- install_requires=[
- 'setuptools'
- ],
include_package_data=True,
entry_points={
- 'buildstream.plugins': [
+ 'buildstream.plugins.elements': [
'autotools = elements.autotools'
]
})
diff --git a/src/buildstream/_elementfactory.py b/src/buildstream/_elementfactory.py
index 5d219c627..89e01a885 100644
--- a/src/buildstream/_elementfactory.py
+++ b/src/buildstream/_elementfactory.py
@@ -36,6 +36,7 @@ class ElementFactory(PluginContext):
plugin_base,
Element,
[_site.element_plugins],
+ "buildstream.plugins.elements",
plugin_origins=plugin_origins,
format_versions=format_versions,
)
diff --git a/src/buildstream/_plugincontext.py b/src/buildstream/_plugincontext.py
index 54839e16b..295482574 100644
--- a/src/buildstream/_plugincontext.py
+++ b/src/buildstream/_plugincontext.py
@@ -30,6 +30,7 @@ from . import utils
# plugin_base (PluginBase): The main PluginBase object to work with
# base_type (type): A base object type for this context
# site_plugin_path (str): Path to where buildstream keeps plugins
+# entrypoint_group (str): Name of the entry point group that provides plugins
# plugin_origins (list): Data used to search for plugins
# format_versions (dict): A dict of meta.kind to the integer minimum
# version number for each plugin to be loaded
@@ -42,7 +43,9 @@ from . import utils
# Pipelines.
#
class PluginContext:
- def __init__(self, plugin_base, base_type, site_plugin_path, *, plugin_origins=None, format_versions={}):
+ def __init__(
+ self, plugin_base, base_type, site_plugin_path, entrypoint_group, *, plugin_origins=None, format_versions={}
+ ):
# For pickling across processes, make sure this context has a unique
# identifier, which we prepend to the identifier of each PluginSource.
@@ -63,6 +66,7 @@ class PluginContext:
# The PluginSource object
self._plugin_base = plugin_base
self._site_plugin_path = site_plugin_path
+ self._entrypoint_group = entrypoint_group
self._alternate_sources = {}
self._format_versions = format_versions
@@ -147,7 +151,7 @@ class PluginContext:
# key by a tuple to avoid collision
try:
- package = pkg_resources.get_entry_info(package_name, "buildstream.plugins", kind)
+ package = pkg_resources.get_entry_info(package_name, self._entrypoint_group, kind)
except pkg_resources.DistributionNotFound as e:
raise PluginError("Failed to load {} plugin '{}': {}".format(self._base_type.__name__, kind, e)) from e
diff --git a/src/buildstream/_sourcefactory.py b/src/buildstream/_sourcefactory.py
index 7c90042a8..254c482d6 100644
--- a/src/buildstream/_sourcefactory.py
+++ b/src/buildstream/_sourcefactory.py
@@ -33,7 +33,12 @@ class SourceFactory(PluginContext):
def __init__(self, plugin_base, *, format_versions={}, plugin_origins=None):
super().__init__(
- plugin_base, Source, [_site.source_plugins], format_versions=format_versions, plugin_origins=plugin_origins
+ plugin_base,
+ Source,
+ [_site.source_plugins],
+ "buildstream.plugins.sources",
+ format_versions=format_versions,
+ plugin_origins=plugin_origins,
)
# create():
diff --git a/tox.ini b/tox.ini
index efb91e75b..30075ee8e 100644
--- a/tox.ini
+++ b/tox.ini
@@ -8,7 +8,7 @@ isolated_build = true
# Configuration variables to share across environments
[config]
-BST_PLUGINS_EXPERIMENTAL_VERSION = 0.14.0
+BST_PLUGINS_EXPERIMENTAL_VERSION = 0.15.0
#
# Defaults for all environments