XD blog

blog page

automation, build, python, travis


2015-02-28 Automated build on Travis for a python module

Many python modules display a small logo which indicates the build status: . I set up the same for the module pyquickhelper which is held on github/pyquickhelper. Travis installs packages before building the modules. The first step is to gather all the dependencies:

pip freeze > requirements.txt

I replaced == by >= and removed some of them, I got:

Cython>=0.20.2
Flask>=0.10.1
Flask-SQLAlchemy>=2.0
Jinja2>=2.7.3
Markdown>=2.4.1
...

The full file is available at: requirements.txt. Next step is to define which instructions Travis needs to run to get the build done. These steps need to be defined in a file .travis.yml. I followed the instructions: Getting started. For my module, I just run the unit tests on python 3.4:

language: python
python:
    - "3.4"
install: 
    - pip install -r requirements.txt
script:
    - python setup.py unittests
    - python setup.py build_sphinx

Once the build is over, I could add a link in README.rst:

.. image:: https://travis-ci.com/sdpython/pyquickhelper.svg?branch=master
    :target: https://app.travis-ci.com/github/sdpython/pyquickhelper
    :alt: Build status

Unfortunately, these settings fail sometimes when others dependencies are needed. Some modules require a fortran compilation and I did not find anything on that subject yet except maybe to use Anaconda distribution on Travis Using Conda with Travis CI (one example I found: .travis.yml).


<-- -->

Xavier Dupré