Skip to main content
 首页 » 编程设计

python之__init__ 模块在使用 setup.py 安装时未被复制

2024年10月24日12dudu

我有以下项目结构设置

/docs 
    releaseNotes.rst 
MANIFEST.in 
/pySan 
    __init__.py 
    __init__.pyc 
    /torrent 
        __init__.py  
        components.py 
    utils.py 
    utils.pyc 
setup.py 
VERSION 

但是当我在 torrent 文件夹中安装 __init__.py 时,没有被复制。

它安装在 /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pySan 和 setup.py是:

from distutils.core import setup 
from os import path 
 
v = open(path.join(path.dirname(__file__), 'VERSION')) 
VERSION = v.readline().strip() 
v.close() 
 
setup( 
    name='pySan', 
    version=VERSION, 
    author='Ciasto Piekarz', 
    author_email='Ciasto_piekarz@gmail.com', 
    packages=['pySan', 'pySan/torrent'], 
    data_files = ['VERSION'], 
    license='LICENSE', 
    description='Package is a collection of commonly used code for all my tools', 
) 

请您参考如下方法:

问题是这一行:

packages=['pySan', 'pySan/torrent'], 

你需要使用包语法:

packages=['pySan', 'pySan.torrent'],