Tutorial: Using NEURON simulator with Python and Travis CI

If you have unit tests or code coverage metrics enabled on your GitHub project that uses the NEURON simulator and you want Travis CI perform those automatically, then you’ll need a Travis CI YAML file that will install NEURON before running the tests.

The script below is essentially a pure script version of the manual steps in my earlier tutorial to install NEURON+Python on Ubuntu.

The script below will run any automated tests you have defined in your repository’s ‘tests’ folder. It supports both Python 2.7 and 3.5 and MPI (single thread only on Travis CI, I believe).

The script below installs NEURON 7.5 with IV 19. Change the versions to desired ones in the urls below as needed.

 
language: python
cache: pip
python:
- "2.7"
- "3.5"
before_install:
- start_dir=$(pwd)
- sudo apt-get update
- sudo apt-get install libx11-dev libxt-dev gnome-devel
- sudo apt-get install mpich
- sudo apt-get install libncurses-dev xfonts-100dpi
- pip install --upgrade pip
- pip install scipy numpy matplotlib cython mpi4py neuronpy
- curl -o nrn.tar.gz https://neuron.yale.edu/ftp/neuron/versions/v7.5/nrn-7.5.tar.gz
- curl -o iv.tar.gz https://neuron.yale.edu/ftp/neuron/versions/v7.5/iv-19.tar.gz
- tar -xvzf nrn.tar.gz
- tar -xvzf iv.tar.gz
- rm *.tar.gz
- mkdir ~/neuron
- mv nrn-7.5 ~/neuron/nrn
- mv iv-19 ~/neuron/iv
- cd ~/neuron/iv
- ./configure --prefix=`pwd`
- make
- make install
- cd ~/neuron/nrn
- python_loc=$(which python)
- ./configure --prefix=`pwd` --with-iv=$HOME/neuron/iv --with-paranrn --with-nrnpython=$python_loc
- make
- make install
- export IV=$HOME/neuron/iv
- export N=$HOME/neuron/nrn
- export CPU=x86_64
- export PATH="$IV/$CPU/bin:$N/$CPU/bin:$PATH"
- cd ~/neuron/nrn/src/nrnpython/
- python setup.py install
- cd $start_dir
install:
- pip install -r requirements.txt
- python setup.py develop
script:
- py.test --cov=hoc2swc tests/
after_success:
- codecov

The script above assumes you have at least these two lines in your
requirements.txt file:

pytest-cov
codecov