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:
什么是合適的方式(或者我將滿足於好的方式)來部署中等復雜度的命令行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
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.
我主要想知道,我的程序入口點應該放在哪里,我如何在路徑上安裝它?setuptools為我創建了它嗎?我試着在HHGTP找到這個,但也許我只是錯過了。
1 个解决方案
#1
7
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 say myproj-bin. Then this would work:
您不需要創建所有這些,. egginfo目錄是由setuptools生成的。您提到了命令行,所以我假設您在某個地方有一個“頂級”腳本,比方說myproject -bin。然后這將工作:
./setup.py
./myproj
./myproj/__init__.py
./scripts
./scripts/myproj-bin
And then put something like this in setup.py:
然后把這樣的東西放到setupy中。
#! /usr/bin/python
from setuptools import setup
setup(name="myproj",
description='shows how to create a python package',
version='123',
packages=['myproj'], # python package names here
scripts=['scripts/myproj-bin'], # scripts here
)
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.
如果您的項目比較復雜,那么您還可以做更多的事情,setuptools的完整手冊在這里:http://peak.telecommunity.com/DevCenter/setuptools。