How can I include package_data without a MANIFEST.in file?

Solution 1:

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 __init__.py of package foo, use

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

I have the layout:

foo/
        __init__.py
        bar.txt
setup.py

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

import setuptools

setuptools.setup(
    name='foo',
    version='2015.3',
    license='commercial',
    packages=setuptools.find_packages(),
    package_data={'foo': ['bar.txt']},
)

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

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

However, if I run your setup.py 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__
'3.6'

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.

Solution 2:

I had the same issue and fixed it be removing :

include_package_data=True