It seems like just adding a package path to your PYTHONPATH gives you access to all of its modules and functions, similar to installing an egg. Is the difference just that the egg is zip compressed?
Python Eggs is a package distribution system that does a lot more than simply copy files and change $PYTHONPATH
.
EDIT: A lot more
meaning e.g. runtime dependency resolution and plugin support. See http://en.wikipedia.org/wiki/EasyInstall.
yes, and zip egg files are decompressed on the fly when you reference them making them slower than when you install it.
Yes absolutely but a bit more read this http://www.ibm.com/developerworks/library/l-cppeak3.html goto section "All about eggs" copied from the above website :
However, this sort of manipulation of the PYTHONPATH (or of sys.path within a script or Python shell session) is a bit fragile. Discovery of eggs is probably best handled within some newish magic .pth files. Any .pth files found in site-packages/ or on the PYTHONPATH are parsed for additional imports to perform, in a very similar manner to the way directories in those locations that might contain packages are examined. If you handle package management with setuptools, a file called easy-install.pth is modified when packages are installed, upgraded, removed, etc. But you may call your .pth files whatever you like (as long as they have the .pth extension). For example, here is my easy-install.pth:
Listing 11. .pth files as configuration of egg locations
% cat /sw/lib/python2.4/site-packages/easy-install.pth import sys; sys.__plen = len(sys.path) setuptools-0.6b1-py2.4.egg SQLObject-0.7.0-py2.4.egg FormEncode-0.5.1-py2.4.egg Gnosis_Utils-1.2.1-py2.4.egg import sys; new=sys.path[sys.__plen:]; del sys.path[sys.__plen:]; p=getattr(sys,'__egginsert',0); sys.path[p:p]=new; sys.__egginsert = p+len(new)
The format is a bit peculiar: it is almost, but not quite, a Python script. Suffice it to say that you may add additional listed eggs in there; or better yet, easy_install will do it for you when it runs. You may also create as many other .pth files as you like under site-packages/, and each may simply list which eggs to make available.