问题
I've got a setup.py file which looks like this:
#!/usr/bin/env python
from setuptools import setup, find_packages
setup(
    name="foo",
    version="1.0",
    packages=find_packages(),
    include_package_data=True,
    package_data={
        "": ["*"],
    },
)
And a package foo which looks like this:
foo/__init__.py
foo/bar.txt
When I run setup.py bdist, the bar.txt file is (correctly) included in the distribution… But when I use setup.py sdist it isn't.
What's up with that? Am I misunderstanding the meaning of package_data? Or is this a quirk of setuptools?
回答1:
There are different sources for selecting those files. The package_data is used for installing from the source tree. The build a source package you also need a MANIFEST.in file. It should contain something like recursive-include *.txt, or whatever you need. 
来源:https://stackoverflow.com/questions/6714145/setuptools-data-files-included-with-bdist-but-not-with-sdist