setuptools python setup.py 安装不复制所有子模块

setuptools python setup.py install not copying all child modules

包目录结构是这样的

repodir/
-------- setup.py
-------- MANIFEST.in

-------- bin/
----------- awsm.sh

-------- sound/
------------ init.py

------------ echo/
----------------- init.py
----------------- module1.py
----------------- module2.py

------------ effects/
------------------- init.py
------------------- module3.py
------------------- module4.py

setup.py

from setuptools import setup
setup(
        name = 'sound',
        version = '0.1',
        author = 'awesomeo',
        author_email = 'awesomeo@email.com',
        description = 'awesomeo',
        license = 'Proprietary',
        packages = ['sound'],
        scripts = ['bin/awsm.sh'],
        install_requires = ['Django==1.8.2', 'billiard', 'kombu', 'celery', 'django-celery' ],
        zip_safe = False,
    )

当我安装 - python setup.py 时,只有 sound/init.py 被复制到 /Library/Python/2.7/site-packages/sound/目录.

其余的子包echo、surround和effects根本没有复制。 Setuptools 创建一个 sound.egg-info,其中包含 SOURCES.txt 文件

SOURCES.txt

MANIFEST.in
setup.py
bin/awsm.sh
sound/__init__.py
sound.egg-info/PKG-INFO
sound.egg-info/SOURCES.txt
sound.egg-info/dependency_links.txt
sound.egg-info/not-zip-safe
sound.egg-info/requires.txt
sound.egg-info/top_level.txt

看起来安装程序不包含要在安装时复制的 SOURCES.txt 文件中的子包,这就是造成问题的原因。

知道为什么会发生这种情况吗?

sound.echosound.effects 添加到 packagesdistutils不会递归收集子包。

根据 fine documentation

Distutils will not recursively scan your source tree looking for any directory with an __init__.py file

注意:还要确保为您的包创建 __init__.py 文件(在您的问题中,您将它们命名为 init.py)。

您已经在使用 setuptools,因此您可以导入 find_packages 以获取所有子包:

from setuptools import setup, find_packages
setup(
    ...
    packages=find_packages(),
    ...
)