2014-01-11 32 views
0

我想在Python 2.7上使用distutils创建一个包安装程序。Python Distutils包分发

这里是我的setup.py

from distutils.core import setup 
import distutils.command.bdist as bdist 

setup_options = { 
    'name': 'tk', 
    'version': '1.0', 
    'description': 'Graphics package that supplements native Tkinter', 
    'package_dir': {'tk': ''}, 
    # this is because setup.py is in the same directory as the package contents 
    'packages': ['tk', 'tk.latex'], 
    } 

setup(**setup_options) 

使用python setup.py bdist --format=wininst,然后用7-Zip的通过可执行一看,我发现文件和文件夹的这个目录:

PURELIB/ # excepted for the executable 
    tk/ # also expected 
    latex/ # subpackage, should not be here 
    some_file_in_tk.py # this should only be located in tk, not in this main directory 

在使用上安装另一台计算机,它按照预期在site-packages下安装tk程序包。但是,它也安装latex子包(tk)和tk中的所有其他文件。为什么会发生这种情况,我可以解决这个问题吗?谢谢!

回答

2

Examples from the docs建议以下目录布局:

<root> 
├── setup.py 
└── tk 
    ├── __init__.py 
    └── latex 
     └── __init__.py 

其中setup.py

from distutils.core import setup 

setup(
    name='tk', 
    version='1.0', 
    description='Graphics package that supplements native Tkinter', 
    packages=['tk', 'tk.latex'], 
)