2014-01-11 35 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'], 
)