Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python equivalent of uber-jar

I'm looking for the equivalent of an uber-jar in the python world.

  • I need to distribute a python package to all three major platforms (Windows, Mac, Linux).
  • It must be bundled with all its dependencies, as the target platform may lack internet.
  • It must be a cross-platform distribution, so I don't have to build for multiple targets. That is, I should be able to run it on all platforms like this:

    python package.ext

You can assume that the package is pure python (no native code). Is there anything that satisfies these requirements?

I know of the following options, each with deficiencies:

  • .whl packages require pip for installation.
  • I don't know how to create an .egg containing all package dependencies.
  • This PEP: http://legacy.python.org/dev/peps/pep-0441 shows that python supports running .zip files, but AFAICT, the best tooling for creating such a zip is pex (https://github.com/pantsbuild/pex), which I think doesn't support Windows
like image 242
Michael Gummelt Avatar asked Jun 22 '16 20:06

Michael Gummelt


1 Answers

One Python alternative to Java's "uber-jar" (made with, say, shade plugin) could be to simply make a tarball of the whole virtual environment, and use it to in your deployment process.

Problem with this approach (as with JAR as well!) is when one of the packages need native libraries. But that is a different story I would say...

Another (modern) alternative is to simply create a Docker image.

like image 171
DejanLekic Avatar answered Oct 08 '22 22:10

DejanLekic