PythonEggs |
UserPreferences |
The PEAK Developers' Center | FrontPage | RecentChanges | TitleIndex | WordIndex | SiteNavigation | HelpContents |
A Python Egg can be used to simplify python distributions. Support may be built in to distutils and the reference python implementation beginning with python 2.5. (There is some support in the Python setuptools sandbox.)
The primary benefits of Python Eggs are:
There are also other benefits that may come from having a standardized format, similar to the benefits of Java's "jar" format. (Eggs are to Pythons as Jars are to Java...)
(Just notes so far)
The following API routines will be available in the pkg_resources module as module-level functions:
These need name, version, python version, and a metadata API, as well as PEP 302 "importer" methods.
For a module that this Distribution controls, return the path for the given resource. Typically implemented as:
return os.path.join(os.path.dirname(module.__file__), resource_name)
Open the path as a file-like object, using the specified mode ('t', 'b', or 'U').
(Note that this does not necessarily return an actual file; if you need a fileno() or an actual operating system file, you should use get_filename() instead.)
Return an openable file or directory path for the given filename. If the filename is not already on the filesystem, it will be extracted to a file allocated by the ResourceManager. If the filename represents a directory, the ResourceManager will allocate files for the entire tree.
The Distribution may allocate more files than requested during this call. A trivial implementation could extract the entire archive's contents, and a complex implementation may decide to extract all object code at the same time (e.g. dll, pyd, so, etc.). Resources that are extracted before they are requested are termed "eager" resources.
This method will be called with the fully qualified name of the module. If the importer is installed on sys.meta_path, it will receive a second argument, which is None for a top-level module, or package.__path__ for submodules or subpackages. It should return a loader object if the module was found, or None if it wasn't. If find_module() raises an exception, it will be propagated to the caller, aborting the import.
See: PEP 302 Importer Protocol
This method returns the loaded module.
See: PEP 302 Loader Protocol
I started doing some of the grunt work for the runtime at:
http://svn.red-bean.com/bob/pyegg/trunk/src/pkg_resources.py
- BobIppolito
And I've implemented a bdist_egg command as part of the Python "setuptools" sandbox. I've also partially implemented another runtime, modulo the open issues listed below. -- PJE
Open issues:
To-Do: