从setup.py安装时未复制yaml文件 [英] yaml file not getting copied when installing from setup.py
问题描述
对于我的distutils包,不会复制yaml文件和python文件
for my distutils package the yaml file along with python files is not getting copied
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
用于将软件包的数据添加到鸡蛋(不推荐使用)和滚轮(不适用于 distutils
).您可能正在生成源代码分发(sdist).
package_data
is used to add package's data to eggs (dropped in favor) and wheels (not with distutils
). You're probably generating source distribution (sdist).
对于sdist,您需要文件 MANIFEST.in
(在 setup.py
之外创建文件).在您的情况下,在其中一行就足够了:
For sdist you need file MANIFEST.in
(create it besides setup.py
). In your case it should be enough to have one line in it:
include package/*.yaml
请参见 https://docs.python.org/3/distutils/sourcedist.html#specifying-the-files-to-distribute
和
https://packaging.python.org/指南/using-manifest-in/#using-manifest-in
如果您不打算创建轮子,则可以安全地从 setup.py
中删除文件
和 package_data
.
If you're not going to create wheels you can safely remove files
and package_data
from setup.py
.
这篇关于从setup.py安装时未复制yaml文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!