分配python命令行工具的最佳方式是什么?
问题描述:
我现在setup.py
脚本作品不错,但它安装tvnamer.py
(工具)作为tvnamer.py
到站点包或类似的地方..分配python命令行工具的最佳方式是什么?
我可以setup.py
安装tvnamer.py
为tvnamer
,和/或是否有更好的办法安装命令行应用程序?
答
尝试setup()调用中的entry_points.console_scripts
参数。如setuptools docs中所述,这应该做我认为你想要的。
要重现此:
from setuptools import setup
setup(
# other arguments here...
entry_points = {
'console_scripts': [
'foo = package.module:func',
'bar = othermodule:somefunc',
],
}
)
当我尝试这与Python 2.6和3.1,我得到一个消息`UserWarning:未知分发选项:“entry_points'`。所以我想它在Python(2.6和3.1)附带的`distutils`中不受支持。那么,如果我们想要在PyPI上发布,可以使用这个选项吗? – 2010-03-17 01:04:02