因此,我有一个基于 pyproject.toml 的小项目(名为
RecordEcos
),可以使用极简界面(使用 PySimpleGUI)进行多摄像头录制。当未连接相机时,界面会使用占位符图像。
我已将以下部分添加到我的 pyproject.toml 中,以确保图像很好地嵌入到轮子中。
[tool.setuptools.package-data]
RecordEcos = ["*.png"]
事实上,一切都在我的笔记本电脑上完美运行:
$ python -m build | grep Placeholder
copying RecordEcos/gui/img/Placeholder.png -> RecordEcos-0.4.5/RecordEcos/gui/img
copying RecordEcos/gui/img/Placeholder.png -> build/lib/RecordEcos/gui/img
copying build/lib/RecordEcos/gui/img/Placeholder.png -> build/bdist.linux-x86_64/wheel/RecordEcos/gui/img
adding 'RecordEcos/gui/img/Placeholder.png'
实际上,即使我不添加 setuptools
package-data
选项,它也可以在我的笔记本电脑上运行。这似乎与 setuptools documentation 非常一致。
所以我已经将其推送到gitlab,CI已被触发...并且生成的轮子不包含图像。
所以可以肯定的是,我已经在 docker 镜像中尝试过:
laptop $ docker run -it python:3.11 /bin/bash
python-container $ pip install build
python-container $ git clone <repository>
python-container $ cd <repository>
python-container & python -m build | grep Placeholder
图片未复制!
有人知道那里发生了什么吗?
我已经尝试过
python:3.11
的 alpine、slim 和 bookworm 版本
ArchLinux 下的笔记本电脑
Python 和包
Python:3.11.8
版本:1.1.1
安装工具:65.6.0
gitlab-ci.yml
build:
stage: build
image: python:3.11-alpine
script:
- pip install build
- python -m build
artifacts:
untracked: false
when: on_success
expire_in: "30 days"
paths:
- dist/
我确实不知道这一点,但我相信您要么需要显式调用 package_data 参数,要么需要设置一个 Manifest 文件。
https://setuptools.pypa.io/en/latest/userguide/miscellaneous.html#using-manifest-in