本文介绍了分发python命令行工具的最好方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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,和/或有更好的方式安装命令行应用程序吗?

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

推荐答案

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

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.

要重现这里:

from setuptools import setup

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

这篇关于分发python命令行工具的最好方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-29 17:35
查看更多