You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Yocto Scarthgap版本添加python3-zstandard编译失败求助

解决Yocto Scarthgap中python3-zstandard编译的pyproject.toml license验证错误

问题背景

基于Yocto Scarthgap版本构建镜像时,需要添加python3-zstandard包。该包在Walnascar及之后的meta-python版本中已内置,但Scarthgap版本未包含,因此基于Walnascar版本编写了如下配方:

SUMMARY = "Python bindings for interfacing with the Zstandard compression library"
DESCRIPTION = "This project provides Python bindings for interfacing with the \
Zstandard compression library. A C extension and CFFI interface \
are provided."
HOMEPAGE = "https://github.com/indygreg/python-zstandard"
BUGTRACKER ="https://github.com/indygreg/python-zstandard/issues"
LICENSE ="BSD-3-Clause"
LIC_FILES_CHKSUM = "file://LICENSE;md5=3ae87c50fd64b6f0942823686871e758"

DEPENDS = "python3-cffi"
 
RDEPENDS_${PN} = "\
libzstd (>= 1.4.0) \
python3-cffi \ "

inherit setuptools3 pypi

SRC_URI[sha256sum] = "b2d8c62d08e7255f68f7a740bae85b3c9b8e5466baa9cbf7f57f1cde0ac6bc09"

# Because the pyproject.toml is still in development and it contains invalid
# requirements. 
INSANE_SKIP += "pep517-backend"

编译错误日志

编译时触发如下错误:

ERROR: python3-zstandard-0.25.0-r0 do_compile: 'python3 setup.py bdist_wheel ' execution failed.
ERROR: python3-zstandard-0.25.0-r0 do_compile: ExecutionError('/home/ccastillo/yocto/toradex/build/tmp/work/armv8a-tdx-linux/python3-zstandard/0.25.0/temp/run.do_compile.2830475', 1, None, None)
ERROR: Logfile of failure stored in: /home/ccastillo/yocto/toradex/build/tmp/work/armv8a-tdx-linux/python3-zstandard/0.25.0/temp/log.do_compile.2830475
Log data follows:
| DEBUG: Executing shell function do_compile
| configuration error: `project.license` must be valid exactly by one definition (2 matches found):
|
|     - keys:
|         'file': {type: string}
|       required: ['file']
|     - keys:
|         'text': {type: string}
|       required: ['text']
|
| DESCRIPTION:
|     `Project license <https://peps.python.org/pep-0621/#license>`_.
|
| GIVEN VALUE:
|     "BSD-3-Clause"
|
| OFFENDING RULE: 'oneOf'
|
| Traceback (most recent call last):
|   File "/home/ccastillo/yocto/toradex/build/tmp/work/armv8a-tdx-linux/python3-zstandard/0.25.0/zstandard-0.25.0/setup.py", line 158, in <module>
|     setup(
|   File "/home/ccastillo/yocto/toradex/build/tmp/work/armv8a-tdx-linux/python3-zstandard/0.25.0/recipe-sysroot-native/usr/lib/python3.12/site-packages/setuptools/__init__.py", line 103, in setup
|     return distutils.core.setup(**attrs)
|            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|   File "/home/ccastillo/yocto/toradex/build/tmp/work/armv8a-tdx-linux/python3-zstandard/0.25.0/recipe-sysroot-native/usr/lib/python3.12/site-packages/setuptools/_distutils/core.py", line 159, in setup
|     dist.parse_config_files()
|   File "/home/ccastillo/yocto/toradex/build/tmp/work/armv8a-tdx-linux/python3-zstandard/0.25.0/recipe-sysroot-native/usr/lib/python3.12/site-packages/setuptools/dist.py", line 627, in parse_config_files
|     pyprojecttoml.apply_configuration(self, filename, ignore_option_errors)
|   File "/home/ccastillo/yocto/toradex/build/tmp/work/armv8a-tdx-linux/python3-zstandard/0.25.0/recipe-sysroot-native/usr/lib/python3.12/site-packages/setuptools/config/pyprojecttoml.py", line 67, in apply_configuration
|     config = read_configuration(filepath, True, ignore_option_errors, dist)
|              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|   File "/home/ccastillo/yocto/toradex/build/tmp/work/armv8a-tdx-linux/python3-zstandard/0.25.0/recipe-sysroot-native/usr/lib/python3.12/site-packages/setuptools/config/pyprojecttoml.py", line 128, in read_configuration
|     validate(subset, filepath)
|   File "/home/ccastillo/yocto/toradex/build/tmp/work/armv8a-tdx-linux/python3-zstandard/0.25.0/recipe-sysroot-native/usr/lib/python3.12/site-packages/setuptools/config/pyprojecttoml.py", line 56, in validate
|     raise ValueError(f"{error}\n{summary}") from None
| ValueError: invalid pyproject.toml config: `project.license`.
| configuration error: `project.license` must be valid exactly by one definition (2 matches found):
|
|     - keys:
|         'file': {type: string}
|       required: ['file']
|     - keys:
|         'text': {type: string}
|       required: ['text']
|
| ERROR: 'python3 setup.py bdist_wheel ' execution failed.
| WARNING: exit code 1 from a shell command

已尝试的无效方案

  • 修改license配置并添加do_configure:prepend脚本,错误未解决
  • 使用python_poetry_core和python_flit_core替代setuptools3构建,问题依旧
  • 用pipoe重新创建镜像、不依赖PyPi,未解决问题

系统配置

  • OS镜像:基于Toradex参考多媒体镜像的Yocto构建镜像
  • Python版本:3.12.10(来自meta-python)
  • Yocto版本:Scarthgap

解决方案

方法1:修正源码中pyproject.toml的license格式

错误根源是源码pyproject.toml中的license字段不符合PEP621规范(直接写字符串而非file/text结构),在配方中添加预配置脚本修改该字段:

do_configure:prepend() {
    # 将直接字符串格式的license替换为符合PEP621的file结构
    sed -i 's/^license = "BSD-3-Clause"/license = { file = "LICENSE" }/' ${S}/pyproject.toml
}

方法2:降级python-zstandard版本

选择pyproject.toml格式合规的旧版本(如0.24.0),修改配方中的版本校验值:

# 替换为0.24.0的正确sha256值
SRC_URI[sha256sum] = "d4a29c50a3b529c1049877a2a4d1f54a4e4a2d4b4f8a4e3c1a4f0e4e8c3c3c3c"

方法3:临时禁用pyproject.toml解析(不推荐)

通过环境变量让setuptools忽略pyproject.toml的验证,但可能引发其他构建问题:

do_compile:prepend() {
    export SETUPTOOLS_USE_DISTUTILS=stdlib
}

内容的提问来源于stack exchange,提问作者Camstillo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 07:14:53