How to include package data with setuptools/distutils?

StackOverflow

When using setuptools, I can not get the installer to pull in any package_data files. Everything I"ve read says that the following is the correct way to do it. Can someone please advise?

setup(
   name="myapp",
   packages=find_packages(),
   package_data={
      "myapp": ["data/*.txt"],
   },
   include_package_data=True,
   zip_safe=False,
   install_requires=["distribute"],
)

where myapp/data/ is the location of the data files.

Answer rating: 331

I realize that this is an old question, but for people finding their way here via Google: package_data is a low-down, dirty lie. It is only used when building binary packages (python setup.py bdist ...) but not when building source packages (python setup.py sdist ...). This is, of course, ridiculous -- one would expect that building a source distribution would result in a collection of files that could be sent to someone else to built the binary distribution.

In any case, using MANIFEST.in will work both for binary and for source distributions.





Get Solution for free from DataCamp guru