Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 27 additions & 21 deletions doc/source/contributing/kiwi_plugin_architecture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,44 +24,51 @@ Task plugin class
implementation of the :file:`process` method.

Task plugin entry point
Registration of the plugin must be done in :file:`setup.py`
using the ``entry_points`` concept from Python's setuptools.
Registration of the plugin must be done in :file:`pyproject.toml`
using the ``tool.poetry.plugins`` concept.

.. code:: python

'packages': ['kiwi_plugin'],
'entry_points': {
'kiwi.tasks': [
'service_command=kiwi_plugin.tasks.service_command'
]
}
[tool.poetry]
name = "kiwi_plugin"

packages = [
{ include = "kiwi_plugin"},
]

[tool.poetry.plugins]
[tool.poetry.plugins."kiwi.tasks"]
service_command = "kiwi_plugin.tasks.service_command"

Example plugin
--------------

.. note::

The following example assumes an existing Python project
which was set up according to the Python project rules
and standards.
which was set up using poetry and pyproject.toml.

1. Assuming the project namespace is **kiwi_relax_plugin**, create the task
plugin directory :file:`kiwi_relax_plugin/tasks`

2. Create the entry point in :command:`setup.py`.
2. Create the entry point in :command:`pyproject.toml`.

Assuming we want to create the service named **relax** that has
the command **justdoit**, this is the following entry point
definition in :file:`setup.py`:
the command **justdoit**, this is the required plugin
definition in :file:`pyproject.toml`:

.. code:: python

'packages': ['kiwi_relax_plugin'],
'entry_points': {
'kiwi.tasks': [
'relax_justdoit=kiwi_relax_plugin.tasks.relax_justdoit'
]
}
[tool.poetry]
name = "kiwi_relax_plugin"

packages = [
{ include = "kiwi_relax_plugin"},
]

[tool.poetry.plugins]
[tool.poetry.plugins."kiwi.tasks"]
relax_justdoit = "kiwi_relax_plugin.tasks.relax_justdoit"

3. Create the plugin code in the file
:file:`kiwi_relax_plugin/tasks/relax_justdoit.py` with the following
Expand Down Expand Up @@ -106,5 +113,4 @@ Example plugin

.. code:: bash

$ ./setup.py develop
$ kiwi-ng relax justdoit --now
$ poetry run kiwi-ng relax justdoit --now
4 changes: 2 additions & 2 deletions package/python-kiwi-pkgbuild-template
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ pkgrel=0
pkgdesc="KIWI - Appliance Builder Next Generation"
url="https://github.com/SUSE/kiwi/tarball/master"
license=('GPL3')
makedepends=(make gcc python-build python-docopt python-installer python-lxml python-poetry-core python-requests python-setuptools python-simplejson python-sphinx python-sphinx_rtd_theme python-wheel python-yaml shadow grep)
makedepends=(make gcc python-build python-docopt python-installer python-lxml python-poetry-core python-requests python-simplejson python-sphinx python-sphinx_rtd_theme python-wheel python-yaml shadow grep)
provides=(kiwi-ng kiwi)
source=("${pkgname}.tar.gz")
changelog="${pkgname}.changes"
Expand All @@ -27,7 +27,7 @@ build() {
}

package_python-kiwi(){
depends=(python-docopt python-simplejson python-lxml python-requests python-setuptools python-yaml grub qemu squashfs-tools gptfdisk pacman e2fsprogs xfsprogs btrfs-progs libisoburn lvm2 mtools parted multipath-tools rsync tar shadow screen kiwi-man-pages)
depends=(python-docopt python-simplejson python-lxml python-requests python-yaml grub qemu squashfs-tools gptfdisk pacman e2fsprogs xfsprogs btrfs-progs libisoburn lvm2 mtools parted multipath-tools rsync tar shadow screen kiwi-man-pages)
optdepends=('gnupg: keyring creation for APT package manager')
cd kiwi-${pkgver}
python3 -m installer --destdir "${pkgdir}/" dist/*.whl
Expand Down
6 changes: 4 additions & 2 deletions package/python-kiwi-spec-template
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,12 @@ BuildRequires: python%{python3_pkgversion}-docopt >= 0.6.2
%else
BuildRequires: python%{python3_pkgversion}-docopt-ng
%endif
%if 0%{?debian} || 0%{?ubuntu}
# only because of debbuild
BuildRequires: python%{python3_pkgversion}-setuptools
%endif
BuildRequires: python%{python3_pkgversion}-lxml
BuildRequires: python%{python3_pkgversion}-requests
BuildRequires: python%{python3_pkgversion}-setuptools
BuildRequires: python%{python3_pkgversion}-simplejson
%if 0%{?suse_version}
BuildRequires: python%{python3_pkgversion}-Sphinx
Expand Down Expand Up @@ -445,7 +448,6 @@ Requires: python%{python3_pkgversion}-docopt-ng
%endif
Requires: python%{python3_pkgversion}-lxml
Requires: python%{python3_pkgversion}-requests
Requires: python%{python3_pkgversion}-setuptools
Requires: python%{python3_pkgversion}-xmltodict
%if ! (0%{?rhel} && 0%{?rhel} < 8)
Recommends: kiwi-man-pages
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ docopt-ng = ">=0.9.0"
lxml = ">=4.6.0"
requests = ">=2.25.0"
PyYAML = ">=5.4.0"
setuptools = ">=50"
simplejson = ">=3.17.0"

# Optional dependencies for markup extra
Expand Down
Loading