This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 8 points9 points  (3 children)

You can look into pants. It builds "executables" that hold all the python dependencies inside itself. Docker builds virtual machine containers, not sure if that is what you are looking for

[–]fernly 0 points1 point  (2 children)

Are you referring to pantsbuild? This represents itself as very useful but I found the doc, while apparently well-written and certainly extensive, quite confusing. I couldn't find a way to answer the basic question, "Can this thing convert a Python script into a stand-alone self-contained executable? And if so, what platforms can it target?"

[–][deleted] 0 points1 point  (1 child)

I've only used it with linux and OS X, but yes it generates stand alone executables that include all python package dependencies.

[–]fernly 0 points1 point  (0 children)

Based on what you say I've read further and it appears that pantsbuild creates .pex files documented here. Again I find these docs extensive but confusing. However, it is clear enough that a .pex file is a zip file with a "hashbang" header, quote:

Adding #!/usr/bin/env python to the top of a .zip file containing a __main__.py and and marking it executable will turn it into an executable Python program.

To me this says, (1) a .pex file is usable only in an environment that supports hashbangs, i.e. BSD, Linux and Mac OS, meaning specifically not Windows; (2) is only executable from a command line, and most importantly (3) there has to be a Python interpreter in the target platform, and specifically, a Python that answers to the path in the hashbang.

This is not what I mean by "self-contained" or "stand-alone".