分发python命令行工具的最佳方法是什么?
时间:2020-03-05 18:41:05 来源:igfitidea点击:
我当前的setup.py
脚本可以正常工作,但是它将tvnamer.py
(工具)作为tvnamer.py
安装到站点包或者类似的地方。
我可以使setup.py以tvnamer的形式安装tvnamer.py,和/或者有没有更好的方式来安装命令行应用程序?
解决方案
回答
在setup()调用中尝试使用entry_points.console_scripts
参数。如setuptools文档中所述,这应该可以完成我认为想要的操作。
要在此处复制:
from setuptools import setup setup( # other arguments here... entry_points = { 'console_scripts': [ 'foo = package.module:func', 'bar = othermodule:somefunc', ], } )