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

2024-04-28 21:57:34 发布

您现在位置:Python中文网/ 问答频道 /正文

包目录结构如下

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

设置.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/directory。

其余的子包回声、环绕和效果根本不复制。Setuptools创建包含SOURCES.txt文件的sound.egg-info

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文件中的子包,这就是造成问题的原因。

知道为什么会这样吗?


Tags: inpyinfotxtbininiteggsh
2条回答

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

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

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)。

相关问题 更多 >