Search code examples
python-3.xlinuxyoctobitbakepodman

Yocto Bitbake podman-py setuptools installation from Github fails


I am using Yocto to build an OS image for an embedded Linux target. Yocto is running on Ubuntu 20.04 and is using dunfell for all meta layers.

The resulting image has Python 3.8 installed, and includes the python3-requests package.

Now, I am trying to write a bitbake recipe to install the 'podman-py' ( https://github.com/containers/podman-py ) package ( which is not on PyPi ).

Here is my current version of the bitbake recipe:

SUMMARY = "This python package is a set of bindings to use the new RESTful API in libpod."
HOMEPAGE = "https://github.com/containers/podman-py"

LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e"

inherit setuptools3

DEPENDS += "python3-requests"

SRCREV = "312b7434843e2ff653e46f9c837e6eeb491c8bff"
PV = "1.0.0+git${SRCPV}"

S = "${WORKDIR}/git"
SRC_URI="git://[email protected]/containers/podman-py.git;branch=master;protocol=ssh"

DEPENDS += "python3-pip-native"

Even though I have python3-requests installed successfully in the resulting image, Yocto throws the following error:

| ModuleNotFoundError: No module named 'requests'
| ERROR: 'python3 setup.py build ' execution failed.
| WARNING: /home/me/Desktop/poky/build-microchip/tmp/work/cortexa5t2hf-neon-vfpv4-poky-linux-musleabi/python3-podman-py/1.0.0+gitAUTOINC+312b743484-r0/temp/run.do_compile.50185:1 exit 1 from 'exit 1'
| ERROR: Execution of '/home/me/Desktop/poky/build-microchip/tmp/work/cortexa5t2hf-neon-vfpv4-poky-linux-musleabi/python3-podman-py/1.0.0+gitAUTOINC+312b743484-r0/temp/run.do_compile.50185' failed with exit code 1:
| Traceback (most recent call last):
|   File "/home/me/Desktop/poky/build-microchip/tmp/work/cortexa5t2hf-neon-vfpv4-poky-linux-musleabi/python3-podman-py/1.0.0+gitAUTOINC+312b743484-r0/git/setup.py", line 3, in <module>
|     import podman
|   File "/home/me/Desktop/poky/build-microchip/tmp/work/cortexa5t2hf-neon-vfpv4-poky-linux-musleabi/python3-podman-py/1.0.0+gitAUTOINC+312b743484-r0/git/podman/__init__.py", line 4, in <module>
|     from podman.api_connection import ApiConnection
|   File "/home/me/Desktop/poky/build-microchip/tmp/work/cortexa5t2hf-neon-vfpv4-poky-linux-musleabi/python3-podman-py/1.0.0+gitAUTOINC+312b743484-r0/git/podman/api_connection.py", line 10, in <module>
|     import podman.containers as containers
|   File "/home/me/Desktop/poky/build-microchip/tmp/work/cortexa5t2hf-neon-vfpv4-poky-linux-musleabi/python3-podman-py/1.0.0+gitAUTOINC+312b743484-r0/git/podman/containers/__init__.py", line 7, in <module>
|     import podman.errors as errors
|   File "/home/me/Desktop/poky/build-microchip/tmp/work/cortexa5t2hf-neon-vfpv4-poky-linux-musleabi/python3-podman-py/1.0.0+gitAUTOINC+312b743484-r0/git/podman/errors/__init__.py", line 8, in <module>
|     from .exceptions import APIError, ImageNotFound, NotFound
|   File "/home/me/Desktop/poky/build-microchip/tmp/work/cortexa5t2hf-neon-vfpv4-poky-linux-musleabi/python3-podman-py/1.0.0+gitAUTOINC+312b743484-r0/git/podman/errors/exceptions.py", line 5, in <module>
|     from requests import Response
| ModuleNotFoundError: No module named 'requests'
| WARNING: /home/me/Desktop/poky/build-microchip/tmp/work/cortexa5t2hf-neon-vfpv4-poky-linux-musleabi/python3-podman-py/1.0.0+gitAUTOINC+312b743484-r0/temp/run.do_compile.50185:1 exit 1 from 'exit 1'

How can I get this package to build with Yocto?


Solution

  • I am not familiar with podman-py, but from looking at your recipe DEPENDS += "python3-requests" means requests is a build dependency. But python3-requests is actually the version for your target which will not be found on your build host.

    So you would need DEPENDS += "python3-requests-native" as a build dependency to run it on your build host. In case you want to add a runtime dependency to requests (to run it on your target machine) you would need to add a RDEPENDS_${PN} += "python3-requests"

    I was able to bake this python3-podman-py_git.bb recipe successfully:

    SUMMARY = "This python package is a set of bindings to use the new RESTful API in libpod."
    HOMEPAGE = "https://github.com/containers/podman-py"
    
    LICENSE = "Apache-2.0"
    LIC_FILES_CHKSUM = "file://LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e"
    
    inherit setuptools3
    
    S = "${WORKDIR}/git"
    SRC_URI="git://[email protected]/containers/podman-py.git;branch=master;protocol=ssh"
    SRCREV = "312b7434843e2ff653e46f9c837e6eeb491c8bff"
    
    DEPENDS += "python3-pip-native python3-requests-native"
    
    BBCLASSEXTEND = "native nativesdk"
    

    However I was not able to test it on a target system, so you might want to include some runtime dependencies.

    Edit: I was a bit confused why the configure task even wants to run/load some podman-py pyhton code. Because configure basically only calls python3 setup.py clean. However podmans setup.py has an import podman in it hence the runtime dependencies need also be present natively.