Github 中的 Yocto Bitbake podman-py setuptools 安装失败

Yocto Bitbake podman-py setuptools installation from Github fails

我正在使用 Yocto 为嵌入式 Linux 目标构建 OS 图像。 Yocto 在 Ubuntu 20.04 上 运行 并且正在为所有元层使用 dunfell。

生成的图像安装了 Python 3.8,并包含 python3-requests 包。

现在,我正在尝试编写一个 bitbake 方法来安装 'podman-py' ( https://github.com/containers/podman-py ) 包(它不在 PyPi 上)。

这是我当前版本的 bitbake 食谱:

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://git@github.com/containers/podman-py.git;branch=master;protocol=ssh"

DEPENDS += "python3-pip-native"

即使我在生成的图像中成功安装了 python3-requests,Yocto 也会抛出以下错误:

| 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'

我怎样才能得到这个包来用 Yocto 构建?谢谢

我不熟悉 podman-py,但是从你的食谱来看 DEPENDS += "python3-requests" 意味着 requests 是一个构建依赖项。但是 python3-requests 实际上是您的目标版本,它不会在您的构建主机上找到。

因此您需要 DEPENDS += "python3-requests-native" 作为构建主机上 运行 的构建依赖项。 如果你想添加一个 运行time 依赖到 requests (在你的目标机器上 运行 它)你需要添加一个 RDEPENDS_${PN} += "python3-requests"

我能够成功烘烤这个 python3-podman-py_git.bb 食谱:

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://git@github.com/containers/podman-py.git;branch=master;protocol=ssh"
SRCREV = "312b7434843e2ff653e46f9c837e6eeb491c8bff"

DEPENDS += "python3-pip-native python3-requests-native"

BBCLASSEXTEND = "native nativesdk"

但是我无法在目标系统上对其进行测试,因此您可能希望包含一些 运行时间依赖性。

编辑: 我有点困惑为什么 configure 任务甚至想要 run/load 一些 podman-py pyhton 代码。因为configure基本上只会调用python3 setup.py clean。然而 podmans setup.py 中有一个 import podman 因此 运行 时间依赖性也需要在本地存在。