[Python-Dev] PEP 273 - Import from Zip Archives (original) (raw)

James C. Ahlstrom jim@interet.com
Thu, 28 Feb 2002 12:02:27 -0500


Skip Montanaro wrote:

Gordon> [Thomas Heller] >> > Have you looked at imputil? It bootstraps itself only from builtin >> > modules (which may be the only mechanism to be in the core).

Gordon> True when Greg wrote it, but strop is now depecrated, and not Gordon> necessarily builtin. It's still the best route, because strop Gordon> has no dependencies, while string does. What do strop or string provide that string methods don't? It's likely that if you needed to import either in the past, you don't need to now.

The real problem isn't the string module, it is the os module. Any importer will need this. The usual hack is to duplicate its logic in the my_importer module. That is, the selection of the correct builtin os functions.

And MAL's point that you need a C importer to import your Python importer is inescapable.

And suppose the whole Python library is in a zip file? You must have additional C code to extract and load your Python importer as well as the modules it imports.

It seems to me that the correct solution is to use the C importer to import the my_importer Python module, plus all the imports that my_importer needs. Then you switch to resolving imports with my_importer.py. Something like this is already in my import.c patch.

I don't think this discussion should hold up installing my zip import patches. I believe these patches are required, and can be the basis of a subsequent patch to add an external Python importer.

JimA