首页 > 解决方案 > 无法在 yocto 3.1.10 中构建 python3-wsgiref

问题描述

我正在尝试构建一个包含 python 服务 (radicale) 的 Yocto 图像,这需要来自 Python3 的 wsgiref。Wsgiref 是 Python3 的一部分,然而,在 poky 中,没有提供 python3-wsgiref 的默认配方。为了构建它,必须对 poky/meta/recipes-devtools/python/python3/python3-manifest.json 进行以下更改:

-- a/python3-manifest.json
+++ b/python3-manifest.json
@@ -812,6 +812,7 @@
             "unittest",
             "unixadmin",
             "venv",
+            "wsgiref",
             "xml",
             "xmlrpc"
         ],
@@ -1196,6 +1197,37 @@
         ],
         "cached": []
     },
+    "wsgiref": {
+        "summary": "Web Server Gateway Interface Reference Implementation",
+        "rdepends": [
+            "core",
+            "crypt",
+            "datetime",
+            "email",
+            "html",
+            "io",
+            "math",
+            "mime",
+            "netclient",
+            "netserver",
+            "stringold"
+        ],
+        "files": [
+            "${libdir}/python${PYTHON_MAJMIN}/wsgiref/handlers.py",
+            "${libdir}/python${PYTHON_MAJMIN}/wsgiref/headers.py",
+            "${libdir}/python${PYTHON_MAJMIN}/wsgiref/simple_server.py",
+            "${libdir}/python${PYTHON_MAJMIN}/wsgiref/util.py",
+            "${libdir}/python${PYTHON_MAJMIN}/wsgiref/validate.py"
+        ],
+        "cached": [
+            "${libdir}/python${PYTHON_MAJMIN}/wsgiref/__pycache__",
+            "${libdir}/python${PYTHON_MAJMIN}/wsgiref/__pycache__/handlers.*.pyc",
+            "${libdir}/python${PYTHON_MAJMIN}/wsgiref/__pycache__/headers.*.pyc",
+            "${libdir}/python${PYTHON_MAJMIN}/wsgiref/__pycache__/simple_server.*.pyc",
+            "${libdir}/python${PYTHON_MAJMIN}/wsgiref/__pycache__/util.*.pyc",
+            "${libdir}/python${PYTHON_MAJMIN}/wsgiref/__pycache__/validate.*.pyc"
+        ]
+    },
     "xml": {
         "summary": "Python basic XML support",
         "rdepends": [

通过此更改,它将作为 python3 配方的一部分提供。

这是激进的秘诀:

SUMMARY = "CalDAV and CardDAV Server"
HOMEPAGE = "https://radicale.org/"
AUTHOR = "Guillaume Ayoub <guillaume.ayoub@kozea.fr>"
LICENSE = "GPLv3"
LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504"

SRC_URI = "https://files.pythonhosted.org/packages/20/d2/0761fe39ac049b1e39790b051302008eafdc7b399a39268aa2204a0b9613/Radicale-3.0.6.tar.gz"
SRC_URI[md5sum] = "fa0879b70bdcd26477759eee347ea91f"
SRC_URI[sha256sum] = "a9433d3df97135d9c02cec8dde4199444daf1b73ad161ded398d67b8e629fdc6"

S = "${WORKDIR}/Radicale-3.0.6"

RDEPENDS_${PN} = "python3-defusedxml python3-passlib python3-vobject python3-python-dateutil python3-setuptools python3-fcntl python3-wsgiref"

inherit setuptools3

正如你所看到的,python3-wsgiref 被附加到 RDEPENDS_${PN} 并且当我构建整个图像时,一切都构建良好并且服务能够在系统上启动。

但是,我想将对 python3-manifest.json 的更改放入补丁中,并将补丁应用到 bbappend 文件中。为此,我在我的自定义“meta-radicale”层“meta-radicale/recipes-devtools/python/python3_3.8.11.bbappend”中添加了一个 bbappend:

FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
SRC_URI_append = " file://build-wsgiref.patch;patchdir=${WORKDIR} "

上面显示的补丁被放入'meta-radicale/recipes-devtools/python/python3/build-wsgiref.patch'。

这是 meta-radiale 的整个文件树:

meta-radicale/
meta-radicale/recipes-radicale
meta-radicale/recipes-radicale/python
meta-radicale/recipes-radicale/python/python3-versions.inc
meta-radicale/recipes-radicale/python/python3-passlib_1.7.4.bb
meta-radicale/recipes-radicale/python/python3-six_1.16.0.bb
meta-radicale/recipes-radicale/python/python3-vobject_0.9.6.1.bb
meta-radicale/recipes-radicale/python/python3-python-dateutil_2.8.2.bb
meta-radicale/recipes-radicale/python/python3-radicale_3.0.6.bb
meta-radicale/recipes-radicale/python/python3-defusedxml_0.7.1.bb
meta-radicale/recipes-devtools
meta-radicale/recipes-devtools/python
meta-radicale/recipes-devtools/python/python3
meta-radicale/recipes-devtools/python/python3/build-wsgiref.patch
meta-radicale/recipes-devtools/python/python3_3.8.11.bbappend
meta-radicale/conf
meta-radicale/conf/layer.conf

'meta-radicale/recipes-radicale/python/' 下的食谱是由'pipoe -p Radicale --python python3' 创建的,并且工作正常,我测试了它们。

如果我尝试构建图像,我会得到以下输出:

RROR: smokylinux-image-1.0-r0 do_rootfs: Could not invoke dnf. Command '/home/imanoid/workspace/smoky-pi/build/smoky-qemuarm64/tmp/work/qemuarm64-poky-linux/smokylinux-image/1.0-r0/recipe-sysroot-native/usr/bin/dnf -v --rpmverbosity=info -y -c /home/imanoid/workspace/smoky-pi/build/smoky-qemuarm64/tmp/work/qemuarm64-poky-linux/smokylinux-image/1.0-r0/rootfs/etc/dnf/dnf.conf --setopt=reposdir=/home/imanoid/workspace/smoky-pi/build/smoky-qemuarm64/tmp/work/qemuarm64-poky-linux/smokylinux-image/1.0-r0/rootfs/etc/yum.repos.d --installroot=/home/imanoid/workspace/smoky-pi/build/smoky-qemuarm64/tmp/work/qemuarm64-poky-linux/smokylinux-image/1.0-r0/rootfs --setopt=logdir=/home/imanoid/workspace/smoky-pi/build/smoky-qemuarm64/tmp/work/qemuarm64-poky-linux/smokylinux-image/1.0-r0/temp --repofrompath=oe-repo,/home/imanoid/workspace/smoky-pi/build/smoky-qemuarm64/tmp/work/qemuarm64-poky-linux/smokylinux-image/1.0-r0/oe-rootfs-repo --nogpgcheck install gerbera imanoid openssh openssh-sftp-server packagegroup-core-boot python3-radicale run-postinsts sudo vim' returned 1:
DNF version: 4.2.2
cachedir: /home/imanoid/workspace/smoky-pi/build/smoky-qemuarm64/tmp/work/qemuarm64-poky-linux/smokylinux-image/1.0-r0/rootfs/var/cache/dnf
Added oe-repo repo from /home/imanoid/workspace/smoky-pi/build/smoky-qemuarm64/tmp/work/qemuarm64-poky-linux/smokylinux-image/1.0-r0/oe-rootfs-repo
repo: using cache for: oe-repo
not found other for: 
not found modules for: 
not found deltainfo for: 
not found updateinfo for: 
oe-repo: using metadata from Mon 23 Aug 2021 01:56:26 PM UTC.
No module defaults found
--> Starting dependency resolution
--> Finished dependency resolution
Error: 
 Problem: conflicting requests
  - nothing provides python3-wsgiref needed by python3-radicale-3.0.6-r0.aarch64
(try to add '--skip-broken' to skip uninstallable packages or '--nobest' to use not only best candidate packages)

ERROR: Logfile of failure stored in: /home/imanoid/workspace/smoky-pi/build/smoky-qemuarm64/tmp/work/qemuarm64-poky-linux/smokylinux-image/1.0-r0/temp/log.do_rootfs.4376
ERROR: Task (/home/imanoid/workspace/smoky-pi/yocto/meta-smokylinux/recipes-smokylinux/images/smokylinux-image.bb:do_rootfs) failed with exit code '1'

我不明白为什么行为不同,直接修改 python3-manifest.json 与通过补丁修改它时。

标签: python-3.xyoctowsgiref

解决方案


经过一番谷歌搜索,我想我找到了问题的答案:https ://hub.mender.io/t/how-to-work-with-python-applications-and-modules-in-yocto-project/1135

“您可以通过阅读此文件来获取这些单独包的列表:

猫../sources/poky/meta/recipes-devtools/python/python3/python3-manifest.json

如果标准库模块未在上述文件中列出,则它是 python3-misc 包的一部分。”

显然,默认的 python3 配方将所有不属于清单的标准 python 模块自动放入名为“python3-misc”的包中。所以我唯一需要做的就是将'python3-misc'而不是'python3-wsgiref'添加到python3-radicale_3.0.6.bb的RDEPENDS行:

RDEPENDS_${PN} = "python3-defusedxml python3-passlib python3-vobject python3-python-dateutil python3-setuptools python3-fcntl python3-misc"

现在它编译成功并且可以在目标系统中导入wsgiref模块。

但是,至于为什么补丁和编辑清单之间存在差异,我还没有发现。


推荐阅读