Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does setuptools decide which files to keep for sdist/bdist?

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.

like image 436
joeforker Avatar asked May 21 '09 18:05

joeforker


1 Answers

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(),
    include_package_data=True,
    namespace_packages=['package'], 
     package_data = {
        # If any package contains *.txt or *.rst files, include them:
        '': ['*.txt', '*.rst']...

)
like image 109
Jason Baker Avatar answered Oct 26 '22 04:10

Jason Baker