Travis CI OSX MacOS with Python

less than 1 minute read

Travis CI MacOS support is not currently planned to directly support Python, but using Miniconda can still easily enable Python for Travis-CI with osx as in this example.

Do not use language: python for osx or it will give not very meaningful errors.

Template

A typical .travis.yml for MacOS (including Linux) for a Python build looks like:

language: generic 
group: travis_latest 

git:
  depth: 3
  quiet: true

os:
- linux
- osx
  
env:
- TRAVIS_PYTHON_VERSION=3.6

before_install:
- if [[ $TRAVIS_OS_NAME == osx ]]; then
  wget https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh;
  else
  wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
  fi

- bash miniconda.sh -b -p $HOME/miniconda
- export PATH=$HOME/miniconda/bin:$PATH
- hash -r

- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
- conda create -n test python=$TRAVIS_PYTHON_VERSION
- source activate test

install: pip install -e .[tests]

script: pytest -rsv

after_success:
- if [[ $TRAVIS_PYTHON_VERSION == 3.6* && $TRAVIS_OS_NAME == linux ]]; then
  pytest --cov --cov-config=setup.cfg;
  coveralls;
fi

Leave a comment