Add python project based on pyproject.toml to yocto image

Viewed 192

I'm putting together a recipe that's supposed to add amqtt to my image (https://github.com/Yakifo/amqtt). The project only comes with a pyproject.toml but lacks a setup.py. Thus, bitbake is complaining that setup.py cannot be found I'm on branch dunfell and these are the most relevant parts of my recipe:

HOMEPAGE = "https://github.com/Yakifo/amqtt"

SRC_URI = "git://github.com/Yakifo/amqtt;protocol=https"

SRCREV = "4beb912c2a0d58d66140ce68b6a31991c2c48b30"

S = "${WORKDIR}/git"

inherit setuptools3 pypi distutils

Your input is highly appreciated.

2 Answers

As of Yocto Release 4.0 (Kirkstone), installation of Python packages using Poetry is supported via the python_poetry_core class - Release 4.0 Migration Guide - Python Changes

My particular scenario (using Gatesgarth 3.2.3) doesn't really justify the effort in updating to Kirkstone. Just changing the packaging system is not an option (it's not my package I'm trying to install).

My workaround: I've opted to simply use Poetry (1.2.1, the latest at time of writing) to manually build the .tar.gz. It turns out that Poetry generates a setup.py with the info contained in pyproject.toml. I commit that package archive to my Yocto project repo, and override SRC_URI in the appropriate recipe to use it instead of the version from PyPi.

Note that I did have some issues in getting poetry build to run due to TOML format difference between the version that it was written for (which I was unable to zero in on) and the latest. I had to modify the pyproject.toml a bit because of this.

I switched to the pypi installer in the end. The most important parts are:

PYPI_PACKAGE = "amqtt"

inherit pypi setuptools3
Related