Thursday, September 4, 2014

PEX, distribute your standalone python executables

I just discovered PEX. It's pretty simple conceptually. Bundle all your python 2/3 modules in a ZIP file. Add a __main__.py inside with bootstrap magic and set the interpreter to #!/usr/bin/env python* and you're done. That's what PEX does for you, with a few extra bells and whistles.

So I did this:

$ pex -r 'plainbox' -r 'xlsxwriter' -r 'lxml' \
  -e plainbox.public:main -o plainbox

And it worked :-) It's super simple and quite convenient for many things I can think of. If you want to play around with the python3 version you may want to apply this patch (python3 is still a stranger to many developers :P)

You can also download the resulting PlainBox executable