问题
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