mirror of
https://github.com/inventree/inventree-docs.git
synced 2025-04-27 21:26:43 +00:00
parent
2dc8e81511
commit
38257c4095
@ -41,12 +41,41 @@ If you want to make your life easier, try to follow these guidelines; break wher
|
||||
from plugin import InvenTreePlugin, registry
|
||||
from plugin.mixins import APICallMixin, SettingsMixin, ScheduleMixin, BarcodeMixin
|
||||
```
|
||||
- deliver as a package - pip is great for dependency management and pypi can serve as a transparent and reliable delivery infrastructure
|
||||
- deliver as a package (see [below](#packaging))
|
||||
- if you need to use a private infrastructure, use the 'Releases' functions in GitHub or Gitlab. Point to the 'latest' release endpoint when installing to make sure the update function works
|
||||
- tag your GitHub repo with 'inventree' and 'inventreeplugins' to make discovery easier
|
||||
- use GitHub actions to test your plugin regularly (you can [schedule actions](https://docs.github.com/en/actions/learn-github-actions/events-that-trigger-workflows#schedule)) against the 'latest' [docker-build](https://hub.docker.com/r/inventree/inventree) of InvenTree
|
||||
- if you use the AppMixin pin your plugin against the stable branch of InvenTree, your migrations might get messed up otherwise
|
||||
|
||||
### Packaging
|
||||
|
||||
The recommended way of distribution is as a [PEP 561](https://peps.python.org/pep-0561/) compliant package. If you can use the official Package Index (PyPi - [official website](https://pypi.org/)) as a registry.
|
||||
Please follow PyPAs official [packaging guide](https://packaging.python.org/en/latest/tutorials/packaging-projects/) to ensure your package installs correctly suing InvenTrees install mechanisms.
|
||||
|
||||
Your package must expose you plugin class as an [entrypoint](https://setuptools.pypa.io/en/latest/userguide/entry_point.html) with the name `inventree_plugins` to work with InvenTree.
|
||||
|
||||
```setup.cfg
|
||||
# Example setup.cfg
|
||||
[options.entry_points]
|
||||
inventree_plugins =
|
||||
ShopifyIntegrationPlugin = path.to.source:ShopifyIntegrationPluginClass
|
||||
```
|
||||
|
||||
```setup.py
|
||||
# Example setup.py
|
||||
|
||||
import setuptools
|
||||
|
||||
# ...
|
||||
|
||||
setuptools.setup(
|
||||
name='ShopifyIntegrationPlugin'
|
||||
.# ..
|
||||
|
||||
entry_points={"inventree_plugins": ["ShopifyIntegrationPlugin = path.to.source:ShopifyIntegrationPluginClass"]}
|
||||
```
|
||||
|
||||
|
||||
### A simple example
|
||||
This example adds a new action under `/api/action/sample` using the ActionMixin.
|
||||
``` py
|
||||
|
Loading…
x
Reference in New Issue
Block a user