Python has the ability to execute a zip file that contains Python files. This makes it very handy to create an executable zip file.
Here's an example how to do it.
test.py
#!/usr/bin/env python
def say_something(): print "Hello World"
def main(): say_something()
__main__.py
#!/usr/bin/env python
import test
if __name__ == "__main__": test.main()
The __main__.py must be in the root directory of the zip file.
Zip all the Python files so that it looks like below. We don't need to use .zip extension, we can name it anything we want.
test.zip
|-- __main__.py
`-- test.py
To execute it:
python test.zip
and you will see the output as
Hello World