Pylons  - 讨论区

标题:转:【翻译】The Definitive Guide to Pylons(八)

2010年10月22日 星期五 17:04

Understanding Eggs
认识Eggs

Most new Python software including Pylons and all its dependencies are distributed as eggs. Eggs are a new package format which has many extra features over the old distutils packages including the addition of dependency information necessary for the easy_install program we've been using to work.

大多数新的Python软件,包括Pylons及所有依赖软件包,都是以eggs格式发布。Eggs是一种新的封装格式,它具有许多额外的功能是旧的distutils软件包所没有的,包括增加依赖信息,这对于我们一直使用的easy_install程序是必要的。

Tip

If you haven't come across the egg format before you can think of them as being similar to .jar files in Java or .gem files in Ruby.

提示  
如果你还没有遇到过egg格式,可以将它们等同于Java中的jar文件,或Ruby中的.gem文件。

Developers are sometimes slightly wary of using EasyInstall because they perceive it to involve a degree of magic. In fact Python eggs are simply zip files of Python modules with a few meta data files added and if you rename them to .zip you can explore their contents. Module zip files have been supported in Python since version 2.3 so using a zip file instead of a directory structure is nothing new. Some of the more advanced features of eggs such as entry points are covered in Part 3 of the book.

开发者有时会稍微谨慎使用EasyInstall,因为他们认为它有一定程度的取巧。事实上Python eggs仅仅是zip文件的Python模块,外加一些元数据文件,如果你重新命名它们为zip格式,你就可以浏览它们的内容。zip文件模块已经从Python 2.3版本开始支持,因此,使用zip文件而不是目录结构已不是什么新鲜事。一些更先进的eggs功能,如entry points都包含在书中第3部分。

One really useful option for use with easy_install is --always-unzip. This forces EasyInstall to extract all files from the egg packages so that you can browse their source files on the filesystem to see how the packages they contain actually work. Very handy if you are an inquisitive developer! You can set this as a default in your virtual Python environment by changing env/lib/python2.5/distutils/distutils.cfg to:

使用easy_install,一个很有用的参数选项,是--always-unzip。这迫使EasyInstall从egg封装包中提取所有文件,这样你可以在文件系统中浏览它们的源文件中,看看它们包含的软件包如何工作。如果你是一个喜欢尝鲜的开发者,你会发现这非常方便!您可以将它在你的虚拟的Python环境设定为默认,通过修改env/lib/python2.5/distutils/distutils.cfg:

[easy_install]
zip_ok = 0

Later on in the book we'll look at how you can create your own egg files from a Pylons application.

在接下来书的后面,我们会研究如何可以建立自己的Pylons应用的egg文件。

原文: http://hi.baidu.com/zhuifengdenanhai/blog/item/47991395d857200f7bf480b7.html

如下红色区域有误,请重新填写。

    你的回复:

    请 登录 后回复。还没有在Zeuux哲思注册吗?现在 注册 !

    Zeuux © 2024

    京ICP备05028076号