From 5f2e947b0c6695699d5055c33aba43f89c14b2dd Mon Sep 17 00:00:00 2001 From: konradko Date: Sun, 22 Mar 2015 13:31:36 +0000 Subject: [PATCH] Add travis pip wheel caching --- .travis.yml | 5 +++++ custom_pip_install.sh | 31 +++++++++++++++++++++++++++++++ tox.ini | 3 +++ 3 files changed, 39 insertions(+) create mode 100755 custom_pip_install.sh diff --git a/.travis.yml b/.travis.yml index 3eb89dc4f..b3d7a1465 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,10 @@ language: python sudo: false +cache: + directories: + - $HOME/.wheelhouse + env: - TOX_ENV=py27-flake8 - TOX_ENV=py27-docs @@ -28,6 +32,7 @@ env: install: - pip install tox + - export WHEEL_DIR=$HOME/.wheelhouse script: - tox -e $TOX_ENV diff --git a/custom_pip_install.sh b/custom_pip_install.sh new file mode 100755 index 000000000..fb274333f --- /dev/null +++ b/custom_pip_install.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +while [[ $# > 1 ]] +do +requirement="$1" + # Only requirements with "Django" in the name are being cached + if [[ "$requirement" == *"Django"* ]] + then + # Try to install from cache + pip install --no-index --find-links=$WHEEL_DIR "$requirement"; + EXIT_STATUS=$? + # If that fails, try to make a wheel + if [ $EXIT_STATUS -ne 0 ] + then + pip wheel --wheel-dir=$WHEEL_DIR "$requirement"; + EXIT_STATUS=$? + # If that fails, install wheel and make wheel + if [ $EXIT_STATUS -ne 0 ] + then + # Wheel version same as in requirements/requirements-packaging.txt + pip install wheel==0.24.0; + pip wheel --wheel-dir=$WHEEL_DIR "$requirement"; + fi + # Install from cache + pip install --no-index --find-links=$WHEEL_DIR "$requirement"; + fi + else + pip install "$requirement"; + fi +shift +done diff --git a/tox.ini b/tox.ini index c986250c5..df6a63dcb 100644 --- a/tox.ini +++ b/tox.ini @@ -6,6 +6,9 @@ envlist = {py27,py32,py33,py34}-django{17,18beta} [testenv] +install_command = + {toxinidir}/custom_pip_install.sh {packages} + commands = ./runtests.py --fast setenv = PYTHONDONTWRITEBYTECODE=1