安装工具不传递入口点的参数
我正在使用setuptools编写我编写的Python脚本
安装后,我这样做:
$ megazord -i input -d database -v xx-xx -w yy-yy
就像我运行它时一样 ./like_this
但是,我得到:
Traceback (most recent call last):
File "/usr/local/bin/megazord", line 9, in <module>
load_entry_point('megazord==1.0.0', 'console_scripts', 'megazord')()
TypeError: main() takes exactly 1 argument (0 given)
看起来 setuptools 没有将我的参数发送到 main() 进行解析( by optparse)
这是我的entry_points setuptools配置:
entry_points = {
'console_scripts': [
'megazord = megazord.megazord:main',
'megazord-benchmark = megazord.benchmark:main',
'megazord-hash = megazord.mzhash:main',
'megazord-mutate = megazord.mutator:main',
]
}
有什么想法吗?
I'm using setuptools for a Python script I wrote
After installing, I do:
$ megazord -i input -d database -v xx-xx -w yy-yy
Like I would if I was running it ./like_this
However, I get:
Traceback (most recent call last):
File "/usr/local/bin/megazord", line 9, in <module>
load_entry_point('megazord==1.0.0', 'console_scripts', 'megazord')()
TypeError: main() takes exactly 1 argument (0 given)
Which looks like setuptools is not sending my arguments to main() to be parsed (by optparse)
Here's my setuptools config for entry_points:
entry_points = {
'console_scripts': [
'megazord = megazord.megazord:main',
'megazord-benchmark = megazord.benchmark:main',
'megazord-hash = megazord.mzhash:main',
'megazord-mutate = megazord.mutator:main',
]
}
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只是为了全面了解 Megazord.py 的外观,使用 @Jeffrey Harris 建议使用一个很好的库来解析输入。
像上面那样使用它,就会得到
And 因为它们都是可选参数,
Just to give a full picture of what
megazord.py
would look like, using @Jeffrey Harris suggestion to use a nice library for parsing the inputs.And with using it like in the above, one would get
And since they are all optional arguments,
setuptools console_scripts 入口点需要一个没有参数的函数。
令人高兴的是, optparse (命令行选项的解析器)不需要传递任何参数,它将读取 sys.argv[1:] 并将其用作输入。
The setuptools console_scripts entry point wants a function of no arguments.
Happily, optparse (Parser for command line options) doesn't need to be passed any arguments, it will read in sys.argv[1:] and use that as it's input.