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

时间:2022-09-12 07:30:23

The package dir structure is this

软件包目录结构是这样的

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

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

When I do - python setup.py install, only sound/init.py is copied to /Library/Python/2.7/site-packages/sound/ directory.

当我做- python设置。py安装,只有声音/ init。py被复制到/Library/Python/2.7/site-packages/sound/ directory。

The rest of the subpackages echo, surround and effects are not copied at all. Setuptools creates an sound.egg-info which contain SOURCES.txt file

其余的子包回显、环绕和效果都不会被复制。Setuptools创建了一个声音。egg-info含有来源。txt文件

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

Looks like setup does not include the subpackages in the SOURCES.txt file to be copied on install and that is what is creating the problem.

看起来安装程序不包含源中的子包。要在安装时复制的txt文件,这就是问题所在。

Any idea why this might happen?

你知道为什么会这样吗?

2 个解决方案

#1


6  

Add sound.echo and sound.effects to packages. distutils won't recursively collect sub-packages.

添加声音。回声和声音。影响包。distutils不会递归地收集子包。

As per the fine documentation:

根据罚款文件:

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

Distutils不会递归地扫描您的源树,以查找任何带有__init__的目录。py文件

Note: Also be sure to create __init__.py files for your packages (In your question you named them init.py).

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

#2


11  

You're already using setuptools so you can import find_packages to get all sub packages:

您已经使用了setuptools,因此可以导入find_package来获得所有子包:

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

#1


6  

Add sound.echo and sound.effects to packages. distutils won't recursively collect sub-packages.

添加声音。回声和声音。影响包。distutils不会递归地收集子包。

As per the fine documentation:

根据罚款文件:

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

Distutils不会递归地扫描您的源树,以查找任何带有__init__的目录。py文件

Note: Also be sure to create __init__.py files for your packages (In your question you named them init.py).

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

#2


11  

You're already using setuptools so you can import find_packages to get all sub packages:

您已经使用了setuptools,因此可以导入find_package来获得所有子包:

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