*sharing a tip that came from "Facundo Batista" on PyConBrasil *
This is a way to pack a Python module as a .jar in Java
Fisrt we need to create a directory called foo, and create a __init__ file
to became a Python module
$mkdir foo
$touch foo/__init__.py
Then create/edit a file
$vi foo/bar.py
Something inside the file:
def foobar():
print "Executing foobar function"
After that we create a new file called __main__.py in the same level as foo
directory
from foo.bar import foobar
foobar()
The tree
$ tree . .
├── foo
│ ├── bar.py
│ └── __init__.py
└── __main__.py
Until here, nothing new, but now we have to create a .zip file and pack it
all
$zip blablabla.zip __main__.py foo
The magic is here:
$python blablabla.zip
Executing foobar function
*YES! You can call a .zip file with Python! *
More on this..* (the real magic is here)*
Create a file called "xpto" with no extension
$vi xpto
Inside xpto write a python call and a write line:
#!/usr/bin/python
# <blank line here>
Now, we have to include the whole content of blablabla.zip into this file
and give it execute permission.
$cat blablabla.zip >> xpto
$chmod +x xpto
DONE! Lets run
$ ./xpto
Executing foobar function
--
I saw the tip here
http://codando.com.br/2010/10/25/o-melhor-hack-para-python/