views:

815

answers:

1

I'm working on a Python package that uses namespace_packages and find_packages() like so in setup.py:

from setuptools import setup, find_packages
setup(name="package",
    version="1.3.3.7",
    package=find_packages(),
    namespace_packages=['package'], ...)

It isn't in source control because it is a bundle of upstream components. There is no MANIFEST.

When I run python setup.py sdist I get a tarball of most of the files under the package/ directory but any directories that don't contain .py files are left out.

What are the default rules for what setup.py includes and excludes from built distributions? I've fixed my problem by adding a MANIFEST.in with

recursive-include package *

but I would like to understand what setuptools and distutils are doing by default.

+2  A: 

You need to add a package_data directive. For example, if you want to include files with .txt or .rst extensions:

from setuptools import setup, find_packages
setup(name="package",
    version="1.3.3.7",
    package=find_packages(),
    namespace_packages=['package'], 
     package_data = {
        # If any package contains *.txt or *.rst files, include them:
        '': ['*.txt', '*.rst']...

)
Jason Baker