entry_points不能在Python中使用pip或easy_install创建自定义脚本吗? [英] entry_points does not create custom scripts with pip or easy_install in Python?

查看:105
本文介绍了entry_points不能在Python中使用pip或easy_install创建自定义脚本吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用简单的入口点来制作自定义脚本,该脚本位于setup.py中:

I am using simple entry points to make a custom script, with this in setup.py:

  entry_points = {
           'my_scripts': ['combine_stuff = mypackage.mymod.test:foo']
  }

其中mypackage/mymod/test.py包含:

import argh
from argh import arg
@arg("myarg", help="Test arg.")
def foo(myarg):
    print "Got: ", myarg

当我使用此软件包安装软件包时(与setup.py在同一目录中)

When I install my package using this (in same directory as setup.py)

pip install --user -e .

入口点似乎根本没有得到处理.为什么会这样?

The entry points do not get processed at all it seems. Why is that?

如果我使用distribute easy_install进行安装,例如:

If I install with distribute easy_install, like:

easy_install --user -U .

然后处理入口点并创建:

then the entry points get processed and it creates:

$ cat mypackage.egg-info/entry_points.txt 
[my_scripts]
combine_stuff = mypackage.mymod.test:foo

,但是在我的bin目录中没有放置任何名为combine_stuff的实际脚本(例如~/.local/bin/).它似乎似乎没有被制造出来.这是怎么了?如何获得可执行的脚本,并且理想情况下也可以与pip一起使用?

but no actual script called combine_stuff gets placed anywhere in my bin dirs (like ~/.local/bin/). It just doesn't seem to get made. What is going wrong here? How can I get it to make an executable script, and ideally work with pip too?

推荐答案

答案是使用console_scripts而不是my_scripts.不清楚脚本的名称不是程序员的内部标签.

The answer was to use console_scripts instead of my_scripts. It was unclear that the scripts name was anything other than internal label for the programmer.

这篇关于entry_points不能在Python中使用pip或easy_install创建自定义脚本吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆