anaconda-python-buildpack

by ibisnetworks

GitHub Readme.md

Anaconda Python Buildpack

This is a Heroku Buildpack for Conda, the Python distribution for scientific computing by Continuum Analytics.

This buildpack enables the installation of binary packages through the open source conda application. Conda is recognized as being core to Continuum's Anaconda Scientific Python distro but it's also at the heart of the lighter weight Miniconda distro which we use here to install only the binary packages we need for our apps deployed on Heroku.

Origin and Changes

This buildpack is derived (and largely follows) Kenneth Reitz's original buildpack for Anaconda python. Reitz is the product owner for Python at Heroku, so it's a good base to work from. Reitz's buildpack

I decided not to use his buildpack directly because (a) it changes fairly often, and (b) I wanted the latitude to add and remove some things for our purposes over time.

Configuring Packages

To control what binary packages are installed by conda when constructing an image using this buildpack, supply a conda-requirements.txt file in the repository you're building an app within.

You can also still supply a requirements.txt file for pip to process. In this way, you can install binary packages via conda for everything you can and still use pip for anything you can't.

The latter strategy is good for adding Ibis-specific python repositories directly from Github, for example: git+git://github.com/ibisnetworks/analytics-api-client-python.git to add the Analytics API client library.

Usage

Example usage:

$ ls
Procfile  conda-requirements.txt  test-application.py

$ heroku create --buildpack https://github.com/ibisnetworks/anaconda-python-buildpack.git

$ git push heroku master
...
-----> Fetching custom git buildpack... done
-----> Python/Miniconda app detected
-----> Preparing Python/Miniconda Environment (3.5.2)
       installing: python-2.7.6-2 ...
-----> Installing dependencies using Conda
      Fetching packages ...
        bitarray-0.8.1 100% |###############################| Time: 0:00:00  17.53 MB/s00  B/s
        dateutil-2.1-p 100% |###############################| Time: 0:00:00   2.29 MB/s00  B/s
        h5py-2.3.0-np1 100% |###############################| Time: 0:00:00  13.49 MB/s00  B/s
        hdf5-1.8.9-1.t 100% |###############################| Time: 0:00:00  12.20 MB/s00  B/s
        libpng-1.5.13- 100% |###############################| Time: 0:00:00   8.05 MB/s00  B/s
        llvm-3.3-0.tar 100% |###############################| Time: 0:00:03  10.65 MB/s00  B/s
        llvmpy-0.12.6- 100% |###############################| Time: 0:00:00   9.65 MB/s00  B/s
        nltk-2.0.4-np1 100% |###############################| Time: 0:00:00   6.26 MB/s00  B/s
        numba-0.13.2-n 100% |###############################| Time: 0:00:00  11.54 MB/s00  B/s
        numexpr-2.3.1- 100% |###############################| Time: 0:00:00   6.80 MB/s00  B/s
        numpy-1.8.1-py 100% |###############################| Time: 0:00:00   8.82 MB/s00  B/s
        pandas-0.14.0- 100% |###############################| Time: 0:00:00   9.90 MB/s00  B/s
        ...

You can also add it to upcoming builds of an existing application:

$ heroku config:add BUILDPACK_URL=https://github.com/ibisnetworks/anaconda-python-buildpack.git

Fair Warning

Heroku limits the final application footprint (slug) size to 300MB. Start small. In case the slug size limit is exceeded, deleting the build cache through the heroku-repo plugin might help.