PythonEggs

http://peak.telecommunity.com/DevCenter/PythonEggs

概覽

Eggs 之於 python,就像jar 之於Java

python eggs 將python工程和相關的信息進行打包,有一些二進制格式代表eggs,更常見的是.egg壓縮格式.所有的格式都支持包含package-specific data, project-wide metadata, C extensions, and Python code.

最簡單安裝egg的方法是使用Easy Install.可以通過setuptools來創建egg.

egg的優點有:
1.通過easy install來安裝
2..egg文件是0安裝格式,只要把他們放在PYTHONPATH或者sys.path中即可
3.可以包含包信息,比如其他的依賴
4.They allow “namespace packages” (packages that just contain other packages) to be split into separate distributions (e.g. zope., twisted., peak.* packages can be distributed as separate eggs, unlike normal packages which must always be placed under the same parent directory. This allows what are now huge monolithic packages to be distributed as separate components.)
5.They allow applications or libraries to specify the needed version of a library, so that you can e.g. require(“Twisted-Internet>=2.0”) before doing an import twisted.internet.
6.They’re a great format for distributing extensions or plugins to extensible applications and frameworks (such as Trac, which uses eggs for plugins as of 0.9b1), because the egg runtime provides simple APIs to locate eggs and find their advertised entry points (similar to Eclipse’s “extension point” concept).

使用Eggs

Automatic Discovery

Building Eggs

Declaring Dependencies

Developing with Eggs

Running Eggs from Source

Accessing Package Resources

使用__file____path__來定位包的路徑,比如一個模塊需要讀取foo.config:
foo_config = open(os.path.join(os.path.dirname(__file__),'foo.conf').read()

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章