URN Logo
UNIX Resources » Linux » China Linux Forum » Python 编 程 » 11 » [转] The Eggs are Coming...
announcement 声明: 本页内容为中国Linux论坛的内容镜像,文章的版权以及其他所有的相关权利属于中国Linux论坛和相应文章的作者,如果转载,请注明文章来源及相关版权信息。
Resources
China Linux Forum(finished)
Linux Forum(finished)
FreeBSD China(finished)
linuxforum.net
  业界新闻与评论
  自由软件杂谈
  IT 人生
  Linux软件快递
  翻译作坊
  Linux图书与评论
  GNU Emacs/XEmacs
  Linux 中文环境和中文化
  Linux桌面与办公软件
  Linux 多媒体与娱乐版
  自由之窗Mozilla
  笔记本电脑上的Linux
  Gentoo
  Debian 一族
  网络管理技术
  Linux 安装与入门
  WEB服务器和FTP服务器
  域名服务器和邮件服务器
  Linux防火墙和代理服务器应用
  文件及打印服务器
  技术培训与认证
  Linux内核技术
  Linux 嵌入技术
  Linux设备驱动程序
  Linux 集群技术
  LINUX平台数据库
  系统和网络安全
  CPU 与 编译器
  系统计算研究所专栏
  Linux下的GUI软件开发
  C/C++编程版
  PHP 技 术
  Java&jsp技术
  Shell编程技术
  Perl 编 程
  Python 编 程
  XML/Web Service 技术
  永远的Unix
  FreeBSD世界
   
[转] The Eggs are Coming...
Author: xyb    Posted: 2005-03-24 14:21    Length: 3,159 byte(s)
[Original] [Print] [Top]
http://dirtsimple.org/2005/03/eggs-are-coming.html

Bob Ippolito and I hacked out a lot of the Python Eggs implementation today. (My new shorthand for explaining them is "An egg is to a Python as a jar is to Java".) I wrote a "bdist_egg" command for setuptools, which is a Python sandbox project where I prototype potential new distutils features. (Two of my previous setuptools features made it into Python 2.4; I'm hoping eggs will be a no-brainer for inclusion in 2.5, especially since the bdist_egg command doesn't really depend on anything else in setuptools.)

Anyway, if you want to play with it, you'll need to check out python/nondist/sandbox/setuptools, and change your setup.py to import the "setup" function from setuptools instead of from distutils. Then, you can use "setup.py bdist_egg" or "setup.py bdist --formats=egg" or any of the other ways you can specify that same thing.

The resulting .egg file can be added to PYTHONPATH or sys.path, as long as it contains only pure Python modules, or if you have the "pkg_resources" runtime installed. Bob has been working on "pkg_resources", but due to various hitches (including a weird bug in Python's zipimport.c), it doesn't actually work yet. But the idea is that .egg files, unlike normal Python zipimport files, can include C extensions as well as pure Python. The "bdist_egg" command automatically generates pure Python stub modules that request extraction of the extensions when the stub is loaded by the normal zipimport machinery. Extensions (and any other contained files that absolutely have to be "real" files) are extracted to a (configurable) cache directory.

Which reminds me. Remember a few paragraphs ago when I mentioned a couple of setuptools features that made it into Python 2.4? Well, one of those features is a way to specify "package data" files, which are data files that get installed within a package's target directory. "bdist_egg" supports this feature by packing those data files into the egg, where they can be accessed via the standard PEP 302 "loader.get_data()" facility. To simplify your use of this, the "pkg_resources" module offers a resource access API that doesn't care whether the data you're accessing is in a "real" directory, an egg, or a regular zipfile. So, we'll be advocating the addition of pkg_resources to Python 2.5, at least once it's working and stable. In the meantime, we'll probably add an option to the bdist_egg command to bundle pkg_resources inside generated eggs, to ensure that it's available when the egg is used.

There's still a fairly long list of features we want to implement in the runtime, but I'll be pretty happy once we get C extensions and "namespace packages" working right, because that'll give us the same zero-install convenience as Java's "jar" files.
[Original] [Print] [Top]
« Previous thread
一个命令,1分钟的时间,让你搭建一个高效快速的支持Python的LAMP服务器!
Python 编 程
11
Next thread »
刚学python第二天 问题问各位哥哥姐姐 请帮忙~~
     

Copyright © 2007 UNIX Resources Network, All Rights Reserved.      About URN | Privacy & Legal | Help | Contact us
备案序号: 京ICP备05006143    webmaster: webmaster@unixresources.net
This page created on 2008-07-17 04:11:16, cost 0.047011137008667 ms.