by humandx

GitHub Readme.md

Heroku buildpack: Python, Numpy, Scipy, Scikit-learn

This is a Heroku buildpack for Python apps, powered by pip.

Additionally, it adds support for Numpy and Scipy.

Differences to other forks

This buildpack is strongly inspired by @thenovices, @dbrgn, @wyn and @ToonTimbermont. In fact, a lot of code was copied from them. It also uses binaries provided by @thenovices. Thanks a lot.

In contrast to their forks, this buildpack does not require a setup.py, it works with a normal requirements.txt file. Additionally, it is based on the current version of the heroku-buildpack-python. This means that it uses a current version of pip, which gets rid of some stack traces in the deploy log.

Setup, Usage

First of all, it is important that your requirements for Numpy and SciPy use only one of the versions available as precompiled binaries here: https://github.com/dbrgn/npscipy-binaries At the time of this writing, supported versions are:

  • Numpy 1.8.1
  • Scipy 0.14.0

Then specify the buildpack as usual. For a new app:

heroku config:set BUILDPACK_URL=https://github.com/humandx/heroku-buildpack-python-sklearn/

For an existing app:

heroku create --buildpack https://github.com/humandx/heroku-buildpack-python-sklearn/


The buildpack will detect your app as Python if it has the file requirements.txt in the root.

It will use Pip to install your dependencies, vendoring a copy of the Python runtime into your slug.

$ mkdir testheroku
$ cd testheroku
$ git init
$ heroku create --buildpack https://github.com/humandx/heroku-buildpack-python-sklearn/
$ echo -e "numpy==1.7.0\nscipy==0.11.0\nscikit-learn==0.13.1" > requirements.txt
$ git add requirements.txt
$ git commit -m 'Added requirements'
$ git push heroku master
Counting objects: 3, done.
Writing objects: 100% (3/3), 260 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)

-----> Fetching custom git buildpack... done
-----> Python app detected
-----> No runtime.txt provided; assuming python-2.7.4.
-----> Preparing Python runtime (python-2.7.4)
-----> Installing Distribute (0.6.36)
-----> Installing Pip (1.3.1)
-----> Noticed numpy/scipy. Bootstrapping prebuilt binaries.
-----> Creating/downloading binaries.
-----> Creating/downloading numpy bdist.
-----> Creating/downloading scipy bdist.
-----> Moving everything from venv directory to python directory...
-----> Installing dependencies using Pip (1.3.1)
-----> Noticed scikit-learn. Installing...
-----> Setting environment vars...
-----> Installing scikit-learn==0.13.1 via pip
-----> Downloading/unpacking scikit-learn==0.13.1
-----> Running setup.py egg_info for package scikit-learn
-----> Successfully installed scikit-learn
-----> Discovering process types
       Procfile declares types -> (none)
-----> Compiled slug size: 59.6MB
-----> Launching... done, v4
       http://ancient-eyrie-7305.herokuapp.com deployed to Heroku

To git@heroku.com:ancient-eyrie-7305.git
 * [new branch]      master -> master

Runtime options include:

  • python-2.7.8
  • python-3.4.2
  • pypy-2.4.0 (unsupported, experimental)
  • pypy3-2.4.0 (unsupported, experimental)

Other unsupported runtimes are available as well.