yaml file not getting copied when installing from setup.py

感情迁移 提交于 2021-01-29 09:30:11

问题


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"],
) 

this is the project directory structure:

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

回答1:


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).

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

See the docs at https://docs.python.org/3/distutils/sourcedist.html#specifying-the-files-to-distribute

and

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

If you're not going to create wheels you can safely remove files and package_data from setup.py.



来源:https://stackoverflow.com/questions/59694760/yaml-file-not-getting-copied-when-installing-from-setup-py

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!