diff --git a/docs/source/extend_kedro/plugins.md b/docs/source/extend_kedro/plugins.md index adc0bf7821..47d3652fd8 100644 --- a/docs/source/extend_kedro/plugins.md +++ b/docs/source/extend_kedro/plugins.md @@ -4,7 +4,7 @@ Kedro plugins allow you to create new features for Kedro and inject additional c ## Overview -Kedro uses [`setuptools`](https://setuptools.readthedocs.io/en/latest/setuptools.html), which is a collection of enhancements to the Python `distutils` to allow developers to build and distribute Python packages. Kedro uses various entry points in [`pkg_resources`](https://setuptools.readthedocs.io/en/latest/setuptools.html) to provide plugin functionality. +Kedro's extension mechanism is built on [`pluggy`](https://pluggy.readthedocs.io/), a solid plugin management library that was created for the [pytest](https://docs.pytest.org/) ecosystem. `pluggy` relies on [entry points](https://packaging.python.org/en/latest/specifications/entry-points/), a Python mechanism for packages to provide components that can be discovered by other packages using [`importlib.metadata`](https://docs.python.org/3/library/importlib.metadata.html#entry-points). ## Example of a simple plugin @@ -189,7 +189,7 @@ When you are ready to submit your code: 2. Choose a command approach: `global` and / or `project` commands: - All `global` commands should be provided as a single `click` group - All `project` commands should be provided as another `click` group - - The `click` groups are declared through the [`pkg_resources` entry_point system](https://setuptools.readthedocs.io/en/latest/setuptools.html) + - The `click` groups are declared through the [entry points mechanism](https://setuptools.pypa.io/en/latest/userguide/entry_point.html) 3. Include a `README.md` describing your plugin's functionality and all dependencies that should be included 4. Use GitHub tagging to tag your plugin as a `kedro-plugin` so that we can find it diff --git a/kedro/framework/cli/hooks/manager.py b/kedro/framework/cli/hooks/manager.py index eae313a270..19457af690 100644 --- a/kedro/framework/cli/hooks/manager.py +++ b/kedro/framework/cli/hooks/manager.py @@ -7,6 +7,8 @@ from .markers import CLI_HOOK_NAMESPACE from .specs import CLICommandSpecs +logger = logging.getLogger(__name__) + _cli_hook_manager = None _CLI_PLUGIN_HOOKS = "kedro.cli_hooks" @@ -17,6 +19,8 @@ def get_cli_hook_manager(): global _cli_hook_manager if _cli_hook_manager is None: _cli_hook_manager = CLIHooksManager() + _cli_hook_manager.trace.root.setwriter(logger.debug) + _cli_hook_manager.enable_tracing() return _cli_hook_manager @@ -42,7 +46,7 @@ def _register_cli_hooks_setuptools(self) -> None: } if plugin_names: - logging.getLogger(__name__).debug( + logger.debug( "Registered CLI hooks from %d installed plugin(s): %s", len(plugin_names), ", ".join(sorted(plugin_names)), diff --git a/kedro/framework/hooks/manager.py b/kedro/framework/hooks/manager.py index d106a36cee..13a8e5a8b2 100644 --- a/kedro/framework/hooks/manager.py +++ b/kedro/framework/hooks/manager.py @@ -23,6 +23,8 @@ def _create_hook_manager() -> PluginManager: """Create a new PluginManager instance and register Kedro's hook specs.""" manager = PluginManager(HOOK_NAMESPACE) + manager.trace.root.setwriter(logger.debug) + manager.enable_tracing() manager.add_hookspecs(NodeSpecs) manager.add_hookspecs(PipelineSpecs) manager.add_hookspecs(DataCatalogSpecs) @@ -60,10 +62,13 @@ def _register_hooks_setuptools( """ already_registered = hook_manager.get_plugins() + # Method name is misleading: + # entry points are standard and don't require setuptools, + # see https://packaging.python.org/en/latest/specifications/entry-points/ hook_manager.load_setuptools_entrypoints(_PLUGIN_HOOKS) disabled_plugins = set(disabled_plugins) - # Get list of plugin/distinfo tuples for all setuptools registered plugins. + # Get list of plugin/distinfo tuples for all registered plugins. plugininfo = hook_manager.list_plugin_distinfo() plugin_names = set() disabled_plugin_names = set()