Search code examples
linuxyoctopypibitbake

Add PyPi package for Yocto without setup.py


I am using Yocto Kirkstone to create an image for my Linux device. I want to add the PyPi package 'tinydb' that does not already exist as a bitbake recipe. I have used a tool to create a working recipe that I can bitbake. However, when I try to include this recipe into my image, I get the following failure. So I can build the package but not install it. How can I fix this? Thanks.

Reading package lists...
Building dependency tree...
Reading state information...
Package python3-tinydb is not available, but is referred to by another package.
This may mean that the package is missing, has been obsoleted, or
is only available from another source

E: Package 'python3-tinydb' has no installation candidate

However I can successfully do this:

bitbake -c cleansstate python3-tinydb && bitbake python3-tinydb

Bitbake recipe:

# The is automatic generated Code by "makePipRecipes.py"
# (build by Robin Sebastian (https://github.com/robseb) ([email protected]) Vers.: 1.2) 

SUMMARY = "Recipe to embedded the Python PiP Package tinydb"
HOMEPAGE ="https://pypi.org/project/tinydb"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=ee9d91e0565d932659cf275d126c7437"

PROVIDES = "python3-tinydb"

inherit pypi
PYPI_PACKAGE = "tinydb"
SRC_URI[md5sum] = "8738999976febfe7e8ea81c4b1910f9b"
SRC_URI[sha256sum] = "6dd686a9c5a75dfa9280088fd79a419aefe19cd7f4bd85eba203540ef856d564"

Image install line in image:

# Add python packages
IMAGE_INSTALL += "python3-tinydb"

EDIT: I believe maybe the issue is that there is no 'package' in the work directory for Yocto. This may be because there is not setup.py to install the tinydb package:

developer@docker-desktop:~/vendor-nxp-bsp/build-imx8plus/tmp/work/armv8a-poky-linux/python3-tinydb/4.8.0-r0$ ls package
developer@docker-desktop:~/vendor-nxp-bsp/build-imx8plus/tmp/work/armv8a-poky-linux/python3-tinydb/4.8.0-r0$ ls
configure.sstate          image            packages-split       pkgdata-sysroot  recipe-sysroot-native  temp
deploy-debs               license-destdir  pkgdata              pseudo           source-date-epoch      tinydb-4.8.0
deploy-source-date-epoch  package          pkgdata-pdata-input  recipe-sysroot   sysroot-destdir
developer@docker-desktop:~/vendor-nxp-bsp/build-imx8plus/tmp/work/armv8a-poky-linux/python3-tinydb/4.8.0-r0$ ls image/
developer@docker-desktop:~/vendor-nxp-bsp/build-imx8plus/tmp/work/armv8a-poky-linux/python3-tinydb/4.8.0-r0$ ls tinydb-4.8.0/
LICENSE  PKG-INFO  pyproject.toml  README.rst  tests  tinydb

Solution

  • I think it is not enough inherit only pypi for your bitbake recipe in case of TOML. Try to use inherit pypi python_poetry_core.

    As i see tinydb uses the new pyproject.toml mode without setup.py. There is a similar question here. https://stackoverflow.com/a/73815410/19516062

    Souliton is to use python_poetry_core or also you can make a custom do_configure:prepend() which can generate a simple setup.py.