
In general Zip archives store whole branches of a file system. A Python ./Lib zip archive would contain:
N:/python/Python-1.5.2/Lib/string.pyc N:/python/Python-1.5.2/Lib/os.pyc N:/python/Python-1.5.2/Lib/copy.pyc N:/python/Python-1.5.2/Lib/test/testall.pyc
Zip archives are isomorphic to branches of a file system. That means there must be a sys.path for each zip archive file. How would this be specified?
Not true. It's easy (using the proper Zip tools) to creat an archive containing this instead: string.pyc os.pyc copy.pyc testall.pyc Thus the entire archive is considered the directory. The Java "jar" tool uses this approach. It's also easy to have packages in there (again this is what Java does): test/ test/__init__.pyc test/pystone.pyc test_support.pyc (etc.)
The archive format stores modules as dotted names, just as they appear in the import statement. The search path is "." in every archive file by definition. The import statement "import foo" just results in a dictionary lookup for key "foo", not a search through a zip directory along a local search path for "foo.something" where "something" can be pyc, pyo, py, etc.
The intent was to link the archives to the import statement, not re-create a directory tree. It borrowed this feature from the archive formats of Greg and Gordon.
Maybe you've gone overboard. The time it takes to translate the dots into slashes really isn't the big deal.
Are there any zip experts out there? Can zip files satisfy all the design requirements I listed in pylib.html? Is there zip code available? All my code is in Python.
Yes (all of us here at CNRI), yes, yes (we have the spaghetti code). While zip files support compression, they support uncompressed files as well and we could go either way. Their most popular compression format is gzip compatible and can be read and written with the zlib module, which is in the standard Python distribution (even on Windows) -- though to build it you need the zlib C library which is of course external (but solid open source). --Guido van Rossum (home page: http://www.python.org/~guido/)