summaryrefslogtreecommitdiff
path: root/.travis.yml
blob: 9dac64deeb356abb66aca525cbbe46738d661c54 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# PyCrypto .travis.yml file, for travis-ci.org testing.
# See https://travis-ci.org/dlitz/pycrypto for build status.
# See https://docs.travis-ci.com/ for general info about the format of this file.
#os:
#  - linux
#  - osx
matrix:
  include:
    - os: osx
      language: generic
      env: PYENV_VERSION=2.1.3
#addons:
#  apt:
#    packages:
#      - libgmp-dev
sudo: false
#cache:
#  ccache: true
#  pip: true
#  directories:
#    - $HOME/.pyenv/cache
#env:
#  - PYENV_VERSION=2.1.3
#  - PYENV_VERSION=2.2.3
#  - PYENV_VERSION=2.3.7
#  - PYENV_VERSION=2.4.6
#  - PYENV_VERSION=2.5.6
#  - PYENV_VERSION=2.6.9
#  - PYENV_VERSION=2.7.6
#  - PYENV_VERSION=2.7.11
#  - PYENV_VERSION=2.7.11 python_flags=-Qnew
#  - PYENV_VERSION=2.7.11 python_flags=-OO
#  - PYENV_VERSION=2.7.11 PYCRYPTO_CONFIGURE_ARGS=--without-gmp
## pip won't install on Python 3.0 (lack of collections.OrderedDict object?)
##  - PYENV_VERSION=3.0.1
#  - PYENV_VERSION=3.1.5
#  - PYENV_VERSION=3.2.5
#  - PYENV_VERSION=3.3.5
#  - PYENV_VERSION=3.4.0
#  - PYENV_VERSION=3.4.4
#  - PYENV_VERSION=3.5.0
#  - PYENV_VERSION=3.5.1
#  - PYENV_VERSION=3.5.1 PYCRYPTO_CONFIGURE_ARGS=--without-gmp
## PyCrypto does not support PyPy yet.
## See https://github.com/dlitz/pycrypto/pull/59
##  - PYENV_VERSION=pypy-2.3.1
##  - PYENV_VERSION=pypy3-2.3.1
#language: python
before_install:
  # Unexport variables
  - declare +x python_flags
  # List local virtualenvs
  - ls ~/virtualenv || true
  # List the cache for diagnistic purposes
  - ls -l ~/.pyenv/cache || true
  # Show environment
  - if [ "$TRAVIS_SECURE_ENV_VARS" = "false" ] ; then env | sort ; fi
  # Deactivate virtualenv if one is currently in use
  - if [ "$(type -t deactivate)" = "function" ] ; then deactivate ; fi
  # Create pyenv cache directory if it doesn't already exist.
  - mkdir -p ~/.pyenv/cache
  # Create alias for sha256sum
  - |-
      if [ "$TRAVIS_OS_NAME" = "osx" ] ; then
        #gsha256summ </dev/null || echo "NO gsha256sum"
        #sha256summ </dev/null || echo "NO sha256sum"
        #brew update
        #brew install coreutils
        #alias sha256sum=gsha256sum
        #gsha256sum </dev/null || echo "NO gsha256sum"
        #sha256sum </dev/null || echo "NO sha256sum"
        sha256sum() {
          shasum -a 256 "$@"
        }
        #mkdir -p ~/bin
        #echo > ~/bin/sha256sum '#!/bin/sh'
        #echo >> ~/bin/sha256sum 'exec shasum -a 256 "$@"'
        #chmod 755 ~/bin/sha256sum
      fi
  # Download and verify pyenv, or use cached version if available.
  - pyenv_uri=https://github.com/yyuu/pyenv/archive/v20160310.tar.gz
  - pyenv_tarball="$HOME/.pyenv/cache/pyenv-$( basename "$pyenv_uri" )"
  - echo "886e386110bc24e4bfdd560bff0b22db34627fe4be203eacd28ca9e9c2491fcf *${pyenv_tarball}" | sha256sum -c - >/dev/null 2>&1 || wget -O"$pyenv_tarball" -c "$pyenv_uri"
  - echo "886e386110bc24e4bfdd560bff0b22db34627fe4be203eacd28ca9e9c2491fcf *${pyenv_tarball}" | sha256sum -c -
  # Install pyenv into ~/.pyenv and load it
  - tar --strip-components=1 -C ~/.pyenv -xvzf "${pyenv_tarball}"
  - export PATH=~/.pyenv/bin:$PATH
  - eval "$(pyenv init -)"
  # If the selected Python version is installed locally (travis-ci native), activate it.
  # If there's a cached Python that's already been built, extract it.
  # Otherwise, install it using pyenv (if not already installed), and then make a cache tarball of the pristine state of the Python version.
  - |-
      if [ -e ~/virtualenv/python"$PYENV_VERSION"/bin/activate ] ; then
        echo "Using travis-ci native Python: ~/virtualenv/python$PYENV_VERSION"
        . ~/virtualenv/python"$PYENV_VERSION"/bin/activate
        unset PYENV_VERSION
      else
        echo "Using pyenv"
        cache_tarball="$HOME/.pyenv/cache/_built-pyenv-python-${PYENV_VERSION}.tgz"
        cached_dir="$HOME/.pyenv/versions/${PYENV_VERSION}"
        if [ -e "${cache_tarball}.done" ]; then
          echo "Extracting tarball: $cache_tarball -> $cached_dir"
          tar -C / -xzf "$cache_tarball" "$cached_dir"
        else
          echo "pyenv install $PYENV_VERSION"
          pyenv install "$PYENV_VERSION"
          echo "Creating cache tarball: $cache_tarball <- $cached_dir"
          tar -C / -czf "$cache_tarball" "$cached_dir"
          touch "${cache_tarball}.done"
        fi
        pyenv rehash
      fi
      unset cache_tarball cached_dir
script:
  - "major_version=$( python -V 2>&1 | cut -d' ' -f2  | cut -d. -f1 )"
  - if [ "$major_version" -ge 3 ] ; then extra_flags="$extra_flags -bb" ; fi
  - python -tt $extra_flags $python_flags setup.py -q build
  - python -tt $extra_flags $python_flags setup.py test