-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Set up `iris.plugins` namespace package * Provide convenience function to use a plugin * Basic documentation for plugins * Add a hint about plugins when load fails * Expose `use_plugin` in `__all__` * Add example usage * Split plugin documentation to its own page * Document how to create a plugin * Link to documentation * Correct "plain" code block -> "text" * Whatsnew
- Loading branch information
Showing
7 changed files
with
116 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 | ||
|
||
`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 |