Installing Cvxopt, NumPy, and SciPy on Travis CI (Translation post)

Share on reddit

Preface: I want to get back into the habit of writing blog posts, but I haven’t had much time lately to plan content.  I feel like just getting your fingers typing  is half the battle when it comes to writing, so this time I’ve written the English version of a post my husband just made on Qiita.

While my own strengths tend more towards algorithm development and ‘the mathy bits’, my husband is a cloud computing wizard and is thankfully willing to spend his free time helping me set up things like Travis CI.  Travis CI is a tool I’ve been coveting for a long time.  What it does is spin up a virtual machine and run all your unit tests each time a pull request is created or updated.  You can tell at a glance whether the unit tests are passing or failing, which takes a lot of the work out of pull request evaluation.

Who is this guide for?

People who want to use Travis CI to test programs which require the Cvxopt, NumPy, and SciPy packages.


Write the names of all the libraries you need in a file called We’re going to apply pip-compile to this to generate requirements.txt, then run
pip install -r requirements.txt

Here’s the file we used for this project:

Have your tests written in one of the standard Python unit test styles (ex. using unittest).

Writing the .travis.yml file

Cvxopt needs libblas-dev and liblapack-dev in order to install, and similarly SciPy needs gfortran, so we prepare those in advance using addons.apt.packages.

In older versions, sudo apt-get install was used in the before_install section, but when using a container base we can’t use sudo, so addons.apt is used instead.

The finished .travis.yml file looks like this:

where is a file containing your unittests, located in the same folder as the .travis.yml file (otherwise adjust the path accordingly).  Multiple scripts can be added in the script section.

Leave a Reply

Your email address will not be published. Required fields are marked *