From 4fcbebcb3859295c7b5c3c58ba1037d1525bf541 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Mon, 26 Dec 2016 16:44:01 +0000 Subject: [PATCH] .travis/*.sh: use homebrew python3 instead of compiling python3 from source with pyenv This should speed it up a bit, as brew will download a pre-compiled "bottle", whereas pyenv compiles python from source. The current 'python3' formula on homebrew is 3.6.0, so let's use that. --- .travis.yml | 2 +- .travis/after_success.sh | 6 ++++- .travis/install.sh | 51 +++++++++++++++++++--------------------- .travis/run.sh | 10 +++----- 4 files changed, 33 insertions(+), 36 deletions(-) diff --git a/.travis.yml b/.travis.yml index a28f8eaed..4475bc9b0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,7 +22,7 @@ matrix: env: TOXENV=py27-cov - language: generic os: osx - env: TOXENV=py35-cov + env: TOXENV=py36-cov install: - ./.travis/install.sh diff --git a/.travis/after_success.sh b/.travis/after_success.sh index dd71f692f..d113fe7b6 100755 --- a/.travis/after_success.sh +++ b/.travis/after_success.sh @@ -3,5 +3,9 @@ set -e set -x +if [ "$TRAVIS_OS_NAME" == "osx" ]; then + source .venv/bin/activate +fi + # upload coverage data to Codecov.io -[[ ${TOXENV} == *"-cov"* ]] && python -m tox -e codecov +[[ ${TOXENV} == *"-cov"* ]] && tox -e codecov diff --git a/.travis/install.sh b/.travis/install.sh index 44242b226..03cc0b3d8 100755 --- a/.travis/install.sh +++ b/.travis/install.sh @@ -3,34 +3,31 @@ set -e set -x -pip_options="--upgrade" ci_requirements="pip setuptools tox" -if [[ "$(uname -s)" == 'Darwin' ]]; then - # install pyenv from the git repo (quicker than using brew) - git clone https://github.com/yyuu/pyenv.git ~/.pyenv - PYENV_ROOT="$HOME/.pyenv" - PATH="$PYENV_ROOT/bin:$PATH" - eval "$(pyenv init -)" - - case "${TOXENV}" in - py27) - # install pip on the system python - curl -O https://bootstrap.pypa.io/get-pip.py - python get-pip.py --user - ;; - py35) - pyenv install 3.5.2 - pyenv global 3.5.2 - ;; - esac - pyenv rehash - - # add --user option so we don't require sudo - pip_options="$pip_options --user" -else - # on Linux, we're already in a virtualenv; no --user required - : +if [ "$TRAVIS_OS_NAME" == "osx" ]; then + if [[ ${TOXENV} == *"py27"* ]]; then + # install pip on the system python + curl -O https://bootstrap.pypa.io/get-pip.py + python get-pip.py --user + # install virtualenv and create virtual environment + python -m pip install --user virtualenv + python -m virtualenv .venv/ + elif [[ ${TOXENV} == *"py3"* ]]; then + # install/upgrade current python3 with homebrew + if brew list --versions python3 > /dev/null; then + brew upgrade python3 + else + brew install python3 + fi + # create virtual environment + python3 -m venv .venv/ + else + echo "unsupported $TOXENV: "${TOXENV} + exit 1 + fi + # activate virtual environment + source .venv/bin/activate fi -python -m pip install $pip_options $ci_requirements +python -m pip install $ci_requirements diff --git a/.travis/run.sh b/.travis/run.sh index 5e89986e4..6804f7dc2 100755 --- a/.travis/run.sh +++ b/.travis/run.sh @@ -3,12 +3,8 @@ set -e set -x -if [[ "$(uname -s)" == "Darwin" ]]; then - PYENV_ROOT="$HOME/.pyenv" - PATH="$PYENV_ROOT/bin:$PATH" - eval "$(pyenv init -)" +if [ "$TRAVIS_OS_NAME" == "osx" ]; then + source .venv/bin/activate fi -# tox script may not be in the $PATH if we installed as --user -# so we run it as module -python -m tox +tox