分发python命令行工具的最佳方法是什么?

时间:2020-12-11 20:17:27

My current setup.py script works okay, but it installs tvnamer.py (the tool) as tvnamer.py into site-packages or somewhere similar..

我当前的setup.py脚本工作正常,但它将tvnamer.py(该工具)作为tvnamer.py安装到site-packages或类似的地方..

Can I make setup.py install tvnamer.py as tvnamer, and/or is there a better way of installing command-line applications?

我可以将setup.py安装tvnamer.py作为tvnamer,和/或是否有更好的方法来安装命令行应用程序?

1 个解决方案

#1


33  

Try the entry_points.console_scripts parameter in the setup() call. As described in the setuptools docs, this should do what I think you want.

尝试setup()调用中的entry_points.console_scripts参数。正如setuptools文档中所述,这应该做我认为你想要的。

To reproduce here:

要在这里重现:

from setuptools import setup

setup(
    # other arguments here...
    entry_points = {
        'console_scripts': [
            'foo = package.module:func',
            'bar = othermodule:somefunc',
        ],
    }
)

#1


33  

Try the entry_points.console_scripts parameter in the setup() call. As described in the setuptools docs, this should do what I think you want.

尝试setup()调用中的entry_points.console_scripts参数。正如setuptools文档中所述,这应该做我认为你想要的。

To reproduce here:

要在这里重现:

from setuptools import setup

setup(
    # other arguments here...
    entry_points = {
        'console_scripts': [
            'foo = package.module:func',
            'bar = othermodule:somefunc',
        ],
    }
)