On Sun, Mar 31, 2013 at 1:09 PM, Philippe Ombredanne <pombredanne@nexb.com> wrote:
On Sat, Mar 30, 2013 at 8:22 PM, Daniel Holth <dholth@gmail.com> wrote:
Python ZIP Application Support - https://docs.google.com/document/d/1MKXgPzhWD5wIUpoSQX7dxmqgTZVO6l9iZZis8dnr... PEP: 4XX Title: Improving Python ZIP Application Support So I guess that this already-available-yet-hidden-or-little-known feature we had since Python 2.6 will be getting a little light.
Let me ask a few silly questions:
Does this means that any zip with a __main__.py is de-facto already executable? Yes.
What about a wheel with a __main__ ? or an egg? Yes.
Or a source archive where the __main__ calls setup.py install or buildout bootstrap?
Yep.
Is this something to promote?
Why not?
How is this overlapping with other packaging approaches? or possibly replacing them all?
It helps make things easier to install that are themselves installation tools. By the way, after some experimenting this morning, I have figured out how to make this work with Python 2.3 and up in a fairly simple way. It turns out that if you stick a .py file on the front of a zipfile, and you end it with a '#' and a few special characters, then when you run the zipfile with 2.6+, the __main__ is executed, but for 2.3-2.5, the .py header is executed. If this header does sys.path.insert(0, __file__), it then can import things from the zipfile. So, with an appropriate header, you can make a one-size-fits-all executable zipfile. In practice, there are a couple of wrinkles. The magic terminator string, at least for the Windows and Linux boxes I've tested so far, is '\n#\x1a\n\x00\n'. But there are more platforms and builds I *haven't* tested on than those I have.