In a recent project, I needed to setup a web server that could solve quadratic programs via a simple API. Conveniently, as of January 15th, 2015, CVXOPT is included in the list of packages that can be installed using conda (Linux and Mac only). Thanks to the conda buildpack for Heroku created by Kenneth Reitz, the process of adding CVXOPT to a Python app is fairly simple. You can follow this same procedure to add popular scientific python packages (like numpy, scipy, scikit-learn, statsmodels, and pandas) to a Heroku app.
1.0 New Apps
If you are starting a new Python app on Heroku, you can add the conda buildpack using the command:
heroku create YOUR_APP_NAME --buildpack https://github.com/kennethreitz/conda-buildpack.git
1.1 Existing Apps
If you have already setup a Python app on Heroku, you can add the conda buildpack to the existing app using the command:
heroku config:add BUILDPACK_URL=https://github.com/kennethreitz/conda-buildpack.git
Or, if you need to specify the app by name:
heroku config:add BUILDPACK_URL=https://github.com/kennethreitz/conda-buildpack.git --app YOUR_APP_NAME
To use the buildpack, you will need to include two text files in the app directory, requirements.txt and conda-requirements.txt. Just as with the standard Python buildpack, the requirements.txt file lists packages that should be installed using pip. Packages that should be installed using conda are listed in the conda-requirements.txt file. Some of the most useful scientific packages include cvxopt, numpy, scipy, scikit-learn, statsmodels, and pandas. The full list of available conda packages can be found at repo.continuum.io.
That’s it! You can now add CVXOPT to a Python app on Heroku.
2.2 With ATLAS
CVXOPT recommends using ATLAS libraries for a performance improvement over standard BLAS & LAPACK libraries. If you want to use CVXOPT with ATLAS instead of BLAS & LAPACK , I have forked Mr. Reitz’s repository and modified the conda buildpack to accept a custom-requirements.txt file. The file lists packages that should be installed using a customized installation procedure. Currently, only cvxopt-atlas is supported.
To use my forked conda buildpack (fair warning, the repository may not have the most recent version of conda):
heroku config:add BUILDPACK_URL=https://github.com/ericburger/conda-buildpack.git
Include the custom-requirements.txt file in the app directory:
The cvxopt-atlas install procedure will use the atlas library available through conda.
I hope this short tutorial will save someone from a few hours of frustration!