setup.py中的entry_points/console_scripts和脚本之间的区别? [英] Difference between entry_points/console_scripts and scripts in setup.py?
本文介绍了setup.py中的entry_points/console_scripts和脚本之间的区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
基本上,有两种方法可以通过setup.py
将Python控制台脚本安装到我的路径中:
setup(
...
entry_points = {
'console_scripts': [
'foo = package.module:func',
],
}
)
和
setup(
...
scripts = [
'scripts/myscript.sh'
]
)
有什么区别?我看到第一种方法允许我为脚本选择漂亮的特定名称,但是还有其他区别吗?不同的原始用途,兼容性(setuptools,distutils,...?),用法,...?我很困惑,精心准备的详细答复可以帮助我(可能还有其他人)正确理解所有这一切.
(出色)点击包的文档PyPA published these cool docs on the topic.
解决方案
The docs for the (awesome) Click package suggest a few reasons to use entry points instead of scripts, including
- cross-platform compatibility and
- avoiding having the interpreter assign
__name__
to__main__
, which could cause code to be imported twice (if another module imports your script)
Click is a nice way to implement functions for use as entry_points
, btw.
这篇关于setup.py中的entry_points/console_scripts和脚本之间的区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文