Third party plugin¶
Third-party plugins are non-program subdirectories, local modules from
installations such as
The third-party plugin is easy to use, the program can not put the plugin
code into the subdirectory, just use pip install to install to the local
machine, and then pass the
plugin_packages parameter when the
PluginManager is initialized.
This means that anyone can write a package and publish it to pypi, and the user writes requirements.txt and installs the dependent plugin, which is called in the initialization, and almost no need to worry about subsequent third-party plugin upgrades.
It’s a package under the web application, which is part of the web application, and the plugin developer is the user, more see Plugin Structure.
How to develop plugins?¶
The local plugin only needs the first step, and the third party plugin needs
setup.py, which requires the next few steps.
First create a package, the metadata and register functions should be written in
__init__.py, the core code can also be written in this file, of course, the recommended approach is to separate the module.
The first step is actually the process of writing local plugins. In this step, you need to write setup.py, so that local plugins can be (published in pypi, optionally) used by others through pip:
from setuptools import setup
If your plugin contains template directory or static directory, you need to write an additional manifest file
recursive-include flask_pluginkit_demo/templates *
recursive-include flask_pluginkit_demo/static *
The modules required by the following commands can be installed like this:
$ pip install -U pip twine wheel setuptools
pip install . to install to the local environment and
test the plugin functionality.
4.2 If the plugin is as expected, it can be packaged and the command is:
python setup.py sdist bdist_wheel, more parameters to adjust themselves.
4.3 Before the official release, you can post to test.pypi.org, which is
the official pypi test site. The package inside will not be used easily.
The command is:
twine upload --repository-url https://test.pypi.org/legacy/ dist/*
4.4 The test station can look at the interface description and so on
whether it meets the requirements of the heart, and publish it to the
official station without problems, pypi.org, the command is:
twine upload dist/*