Python Distutils包分发

时间:2014-01-11 01:50:49

标签: python

我正在尝试使用Python 2.7上的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

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

1 个答案:

答案 0 :(得分: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'],
)