-
Notifications
You must be signed in to change notification settings - Fork 298
Plugin support #5144
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Plugin support #5144
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
2b0bd26
Set up `iris.plugins` namespace package
vsherratt 301ae91
Provide convenience function to use a plugin
vsherratt e15e4e3
Basic documentation for plugins
vsherratt 67b44a0
Add a hint about plugins when load fails
vsherratt 2d351b5
Expose `use_plugin` in `__all__`
vsherratt 565bde6
Add example usage
vsherratt f531023
Split plugin documentation to its own page
vsherratt f4736e0
Document how to create a plugin
vsherratt f3aca39
Link to documentation
vsherratt 6f1cd1b
Correct "plain" code block -> "text"
vsherratt 502730d
Whatsnew
vsherratt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| .. _namespace package: https://packaging.python.org/en/latest/guides/packaging-namespace-packages/ | ||
|
|
||
| .. _community_plugins: | ||
|
|
||
| Plugins | ||
| ======= | ||
|
|
||
| Iris supports **plugins** under the ``iris.plugins`` `namespace package`_. | ||
| This allows packages that extend Iris' functionality to be developed and | ||
| maintained independently, while still being installed into ``iris.plugins`` | ||
| instead of a separate package. For example, a plugin may provide loaders or | ||
| savers for additional file formats, or alternative visualisation methods. | ||
|
|
||
|
|
||
| Using plugins | ||
| ------------- | ||
|
|
||
| Once a plugin is installed, it can be used either via the | ||
| :func:`iris.use_plugin` function, or by importing it directly: | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| import iris | ||
|
|
||
| iris.use_plugin("my_plugin") | ||
| # OR | ||
| import iris.plugins.my_plugin | ||
|
|
||
|
|
||
| Creating plugins | ||
| ---------------- | ||
|
|
||
| The choice of a `namespace package`_ makes writing a plugin relatively | ||
| straightforward: it simply needs to appear as a folder within ``iris/plugins``, | ||
| then can be distributed in the same way as any other package. An example | ||
| repository layout: | ||
|
|
||
| .. code-block:: text | ||
|
|
||
| + lib | ||
| + iris | ||
| + plugins | ||
| + my_plugin | ||
| - __init__.py | ||
| - (more code...) | ||
| - README.md | ||
| - pyproject.toml | ||
| - setup.cfg | ||
| - (other project files...) | ||
|
|
||
| In particular, note that there must **not** be any ``__init__.py`` files at | ||
| higher levels than the plugin itself. | ||
|
|
||
| The package name - how it is referred to by PyPI/conda, specified by | ||
| ``metadata.name`` in ``setup.cfg`` - is recommended to include both "iris" and | ||
| the plugin name. Continuing this example, its ``setup.cfg`` should include, at | ||
| minimum: | ||
|
|
||
| .. code-block:: ini | ||
|
|
||
| [metadata] | ||
| name = iris-my-plugin | ||
|
|
||
| [options] | ||
| packages = find_namespace: | ||
|
|
||
| [options.packages.find] | ||
| where = lib |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| # Iris plugins | ||
vsherratt marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| `iris.plugins` is a [namespace package] allowing arbitrary plugins to be | ||
| installed alongside Iris. | ||
|
|
||
| See [the Iris documentation][plugins] for more information. | ||
|
|
||
|
|
||
| [namespace package]: https://packaging.python.org/en/latest/guides/packaging-namespace-packages/ | ||
| [plugins]: https://scitools-iris.readthedocs.io/en/latest/community/plugins.html | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.