Skip to content

Instantly share code, notes, and snippets.

@giulioungaretti
Forked from dan-blanchard/.1.miniconda.md
Last active August 29, 2015 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save giulioungaretti/fb2307ddda4eb8aeadad to your computer and use it in GitHub Desktop.
Save giulioungaretti/fb2307ddda4eb8aeadad to your computer and use it in GitHub Desktop.

For ETS's SKLL project, we found out the hard way that Travis-CI's support for numpy and scipy is pretty abysmal. There are pre-installed versions of numpy for some versions of Python, but those are seriously out of date, and scipy is not there are at all. The two most popular approaches for working around this are to (1) build everything from scratch, or (2) use apt-get to install more recent (but still out of date) versions of numpy and scipy. Both of these approaches lead to longer build times, and with the second approach, you still don't have the most recent versions of anything. To circumvent these issues, we've switched to using Miniconda (Anaconda's lightweight cousin) to install everything.

A template for installing a simple Python package that relies on numpy and scipy using Miniconda is provided below. Since it's a common setup, I've also included steps to use Coveralls for calculating test coverage.

All you need to do is replace the YOUR_PACKAGE_NAME_HERE parts with your package's name in both .coveragerc and .travis.yml, and include both files in your project's root directory. Then just activate Travis and you should be set.

You may also consider adding the latest Miniconda shell script to your repository, and modifying your .travis.yml to just use that instead of downloading it every time. It can make building slightly faster, and is more resistent to server issues on Continuum's side (although you still are downloading the packages from them).

Additional files (only show up on roughdraft.io)

.coveragerc

.coveragerc

.travis.yml

.travis.yml

[run]
source = YOUR_PACKAGE_NAME_HERE
omit =
*/python?.?/*
*/lib-python/?.?/*.py
*/lib_pypy/_*.py
*/site-packages/ordereddict.py
*/site-packages/nose/*
*/unittest2/*
language: python
python:
- 2.7
- 3.3
notifications:
email: false
# Setup anaconda
before_install:
- wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh
- chmod +x miniconda.sh
- ./miniconda.sh -b
- export PATH=/home/travis/miniconda/bin:$PATH
- conda update --yes conda
# The next couple lines fix a crash with multiprocessing on Travis and are not specific to using Miniconda
- sudo rm -rf /dev/shm
- sudo ln -s /run/shm /dev/shm
# Install packages
install:
- conda install --yes python=$TRAVIS_PYTHON_VERSION atlas numpy scipy matplotlib nose dateutil pandas statsmodels
# Coverage packages are on my binstar channel
- conda install --yes -c dan_blanchard python-coveralls nose-cov
- python setup.py install
# Run test
script:
- nosetests --with-cov --cov YOUR_PACKAGE_NAME_HERE --cov-config .coveragerc --logging-level=INFO
# Calculate coverage
after_success:
- coveralls --config_file .coveragerc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment