python 命令行应用程序的最佳布局是什么?
布置中等复杂度的命令行 python 应用程序的正确方法是什么(或者我会选择一种好方式)?我使用 Paster 创建了一个 python 项目框架,它给了我一些文件:
myproj/__init__.py
MyProj.egg-info/
dependency_links.txt
entry_points.txt
PKG-INFO
SOURCES.txt
top_level.txt
zip-safe
setup.cfg
setup.py
我主要想知道我的程序入口点应该放在哪里,以及如何将其安装在路径上? setuptools 会为我创建它吗?我试图在 HHGTP 中找到它,但也许我只是错过了它。
What is the right way (or I'll settle for a good way) to lay out a command line python application of moderate complexity? I've created a python project skeleton using paster, which gave me a few files to start with:
myproj/__init__.py
MyProj.egg-info/
dependency_links.txt
entry_points.txt
PKG-INFO
SOURCES.txt
top_level.txt
zip-safe
setup.cfg
setup.py
I want to know, mainly, where should my program entry point go, and how can I get it installed on the path? Does setuptools create it for me? I'm trying to find this in the HHGTP, but maybe I'm just missing it.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不需要创建所有这些,
.egg-info
目录是由 setuptools 生成的。您提到了命令行,所以我假设您在某处有一个“顶级”脚本,比如说myproj-bin
。然后这样就可以了:然后在
setup.py
中添加类似的内容:如果您的项目很复杂,您还可以做更多事情,setuptools 的完整手册在这里:http://peak.telecommunity.com/DevCenter/setuptools。
You don't need to create all that, the
.egg-info
directory is generated by setuptools. You mention the command line, so I assumed you have a 'top level' script somewhere, let's saymyproj-bin
. Then this would work:And then put something like this in
setup.py
:There's a lot more that you can do if your project is complex, the full manual of setuptools is here: http://peak.telecommunity.com/DevCenter/setuptools.