[Python-Dev] Add a -z interpreter flag to execute a zip file

Phillip J. Eby pje at telecommunity.com
Sat Jul 14 20:04:08 CEST 2007


At 03:28 AM 7/15/2007 +1000, Nick Coghlan wrote:
>Jim Jewett wrote:
> > If anything, I would like to see the -m option enhanced so that if it
> > gets a recognized "collection" file type (including a directory or
> > zip), it does the right thing.  Whether that actually makes sense, or
> > defeats the purpose of the -m shortcut, I'm not sure.
>
>-m deals with the package namespace as it already stands - it knows
>nothing whatsoever about the underlying filesystem (and that's
>deliberate - the runpy module relies on PEP 302 to abstract away all
>those details).
>
>On Phillip's idea regarding being able to execute directories and zip
>files, I think the semantics would actually be manageable (as
>directories and zip files can be definitely identified), but I'd be
>concerned as to the startup cost for checking what is being executed.

Well, the start file is being opened and checked for directory-ness 
already, and it has to be read to be executed.  The extra reading to 
see if it's a zipfile isn't likely to be much additional overhead.

At this point I've got a partial patch.  It figures out when it 
should import __main__, but it's not successful at actually doing 
so.  It seems that simply importing or reloading '__main__' doesn't 
work, because it's considered a built-in module.  Apparently, I'll 
have to explicitly load the module via the found importer.



More information about the Python-Dev mailing list