[Distutils] Distributable binary with dependencies

Carl Meyer carl at oddbird.net
Fri Aug 23 18:39:02 CEST 2013

Hi Bharath,

On 08/23/2013 04:45 AM, bharath ravi kumar wrote:
> I'm looking to package an application with all its dependencies for
> deployment on multiple hosts. I'd like to ensure that there is no
> compilation or setup step before starting the application in production.
>  An nice to have ability would be to isolate base library dependencies
> per application (like virtualenv does). Ideally, the development ->
> deployment lifecycle would involve: (a) Build an application archive
> with all its dependencies baked in (b) Copy archive to a host in
> production. (c) Unwrap archive (d) Start services. (Note that the build
> host & production hosts are identical in architecture, OS patch level
> and python version).

Some options if you want zero installation steps on production hosts:

1) Vendor dependencies' Python code directly into your application. You
can use pip to automate this based on requirements files with a script
https://github.com/mozilla/moztrap/blob/master/bin/generate-vendor-lib -
for portability this is normally only possible with pure-Python
dependencies, but in your case if the app will only ever run on
identical servers you could do it for compiled (C-extension)
dependencies as well. One downside is that it generally requires some
kind of sys.path hacking in your application environment or startup to
make the vendor-library importable.

2) Install things into virtualenvs using pip on the build host (possibly
using pre-built wheels to speed that up), and then copy the entire
virtualenv to the production host. If build and production hosts are
identical in every way (including the path of the virtualenv), this will
Just Work. There are also tools like
https://github.com/PolicyStat/terrarium that aim to smooth this workflow.

3) Generate OS packages (debs or rpms) containing your complete app and
installed dependencies. I'd recommend this for the smoothest experience
once you have some tooling in place, but it will probably take some time
initially to develop that tooling. You might find Hynek Schlawack's blog
post on the topic helpful:


More information about the Distutils-SIG mailing list