gpt4 book ai didi

python-2.7 - 从 setup.py 安装时未复制 yaml 文件

转载 作者:行者123 更新时间:2023-12-05 05:06:41 24 4
gpt4 key购买 nike

对于我的 distutils 包,yaml 文件和 python 文件没有被复制

setup.py

from distutils.core import setup

files = ["*.yaml", "package/*"]

setup(name = "mypackage",
version = "0.1",
description = "description",
author = "Ciasto",
author_email = "me@email.com",
packages = ['package'],
package_data = {'package' : files },
scripts = ["scripts/runner"],
)

这是项目目录结构:

$ tree package/
|____
| |______init__.py
| |____command.py
| |____constants.py
| |____controller.py
| |____utils.py
| |____model.py
| |____products.yaml

最佳答案

package_data 用于将包的数据添加到 eggs(放弃)和 wheels(不适用于 distutils)。您可能正在生成源代码分发 (sdist)。

对于 sdist,您需要文件 MANIFEST.in(在 setup.py 之外创建它)。在您的情况下,其中一行就足够了:

include package/*.yaml

请参阅 https://docs.python.org/3/distutils/sourcedist.html#specifying-the-files-to-distribute 上的文档

https://packaging.python.org/guides/using-manifest-in/#using-manifest-in

如果您不打算创建轮子,您可以安全地从 setup.py 中删除 filespackage_data

关于python-2.7 - 从 setup.py 安装时未复制 yaml 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59694760/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com