[Python-Dev] Add a -z interpreter flag to execute a zip file
"Martin v. Löwis"
martin at v.loewis.de
Thu Jul 12 22:53:43 CEST 2007
> The approach is cross-platform, in that you can use the approach on
> different platforms. The result of the approach, however, is not
> cross-platform. You can't distribute your single zip-as-executable to
> both Windows and bourne-shell-using platforms. The -z argument does
> allow that.
I still don't understand how so. How will this work on Windows?
> For instance, you need to set PYTHONPATH to include the
> zipfile before you can import from it, but you don't want that
> PYTHONPATH to be passed to subprocesses by accident.
That's why I say a best-practice solution should be established.
In this case, if the actual main function is invoked through
-c, the -c script could get a sys.path.append statement as
> The -z argument makes it extremely simple: the user decides which python
> to run, and the program is run directly just like it would if it was
> unpacked and run that way.
Really? I think there a still a number of subtleties, like what
sys.argv will be, and how sys.path will look like. It's definitely
*not* the same as if you unzipped it, and ran the unzipped one.
> I disagree with both statements. The bagage is much less than zipimport
> itself, which has proven to be quite useful. Nevertheless, zipimport
> built into the interpreter was by no means necessary; current users of
> it could have readily implemented it themselves, with no changes to
> Python. (In fact, Google's 'autopar' tool does exactly that to support
> Python 2.2, which lacks zipimport.) This is a very small, logical and
> useful extension to zipimport, and I believe you will find more uses for
> it than you expect (although I do believe you yourself don't have a need
> for it. I just don't think you're a typical Python programmer in this
> case :)
Ok. I'll shut up, just hoping that this won't cause too much trouble
in the long run.
More information about the Python-Dev