[yaml文件从setup.py安装时未复制

问题描述 投票:0回答:1

对于我的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 = "[email protected]",
    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
python-2.7 setup.py distutils
1个回答
0
投票

package_data用于将包装的数据添加到鸡蛋(不推荐使用)和车轮(不包含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

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

© www.soinside.com 2019 - 2024. All rights reserved.