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

1

8

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.

Hydrate answered 21/5, 2009 at 18:19 Comment(1)
also see how-files-are-included-in-an-sdistIsbella
B
4

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']...

)
Biyearly answered 21/5, 2009 at 18:22 Comment(1)
Ok I did what you sad. But when i instal it by pip install git+git://repo it does not include files. Are the suppose tu be in curtain level of directory layout?Brutus

© 2022 - 2024 — McMap. All rights reserved.