Re: [Python-Dev] Documentation for ability to execute zipfiles &	directories At 05:40 PM 3/4/2008 +0300, Oleg Broytmann wrote:
>On Wed, Mar 05, 2008 at 12:14:04AM +1000, Nick Coghlan wrote:
> > As a more helpful answer, the ZIP spec allows additional data to be
> > included in the file before the ZIP header. A more common way of using
> > this is to add a zip file on to the end of an ELF executable while still
> > using normal zipfile utilities to read the data in the zip file section
> > and ignore the executable part.
> >
> > It turns out you can actually use the same trick to prepend a shebang
> > line like "/usr/bin/env python" and a newline character
>
>    That's what I thought, too.
>
> > - the whole zip
> > file is still a binary file, but that doesn't prevent the shell from
> > reading that first line of text and handing the file over to Python for
> > execution.
>
>    Unix doesn't distinguish text and binary files. (-:
>
> > The fact that this actually works was also news to me when the issue I
> > linked in my previous post was first brought to my attention :)
>
>    So it really works? Amazing!

Setuptools has been distributed this way for some time:

http://pypi.python.org/pypi/setuptools#cygwin-mac-os-x-linux-other

It actually contains an entire shell script prefix that launches 
Python and invokes an entry point inside the egg.  With the new 
interpreter capability, this would've been a *lot* simpler to implement.

_______________________________________________
Python-Dev mailing list
zvllln-eum@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: http://mail.python.org/mailman/options/python-dev/python-dev%40tangomu.com


