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()

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