How can I include package_data without a file?

TL;DR: The keys in the package_data dictionaries are packages; the values are lists of globs. '' is not a valid name for any Python package.

If you want to have bar.txt be installed next to the of package foo, use

 package_data={'foo': ['bar.txt']}

I have the layout:


Now, if foo is a package like above, do:

import setuptools

    package_data={'foo': ['bar.txt']},

And after python sdist, I check the contents of dist/foo-2015.3.tar.gz

% tar tfz dist/foo-2015.3.tar.gz

However, if I run your with package_data={'': ['foo/bar.txt']}, I can concur that the foo/bar.txt will not be added to the source distribution, except if the foo-2015.3.egg-info/SOURCES.txt already has the line for foo/bar.txt – in that case the file will pop up in the source distribution too

No manifest was used; the setuptools version was 3.6 (I deliberately installed the same, old version that you were using):

>>> import setuptools
>>> setuptools.__version__

The behaviour above also works in standard distutils: 2.6 Installing package data of the “legacy” distutils documentation; with a comment for 2.7, 3.1:

Changed in version [2.7, 3.1]: All the files that match package_data will be added to the MANIFEST file if no template is provided.

Leave a Comment