summaryrefslogtreecommitdiff
path: root/tests/travis/setup.sh
blob: 799b0ff0b20b666fc128dd45ce9685e42dc1de3d (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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
#!/bin/sh

set -e
set -x

wget_once() {
  url="$1"
  if ! test -f `basename "$url"`; then
    wget -O `basename "$url"`.part "$url"
    rv=$?
    if test $rv = 0; then
      mv `basename "$url"`.part `basename "$url"`
    else
      rm -f `basename "$url"`.part
      return $rv
    fi
  fi
}

file_host=https://github.com/pycurl/deps/raw/master
distro=trusty

(cd &&
  mkdir -p opt &&
  cd opt &&
  wget $file_host/bin-$distro-64.tar.xz &&
  tar xfJ bin-$distro-64.tar.xz)

export PATH=~/opt/bin:$PATH

if test -n "$USEPY"; then
  # need to launch tests.appmanager with a more modern python.
  # doing this for 3.1 now.
  pip install -r requirements-dev.txt

  (cd && mkdir -p opt && cd opt &&
    wget $file_host/python-"$USEPY"-$distro-64.tar.xz &&
    tar xfJ python-"$USEPY"-$distro-64.tar.xz)
  export PATH=$HOME/opt/python-$USEPY/bin:$PATH

  mkdir archives && (
    cd archives &&
    wget_once https://pypi.python.org/packages/source/v/virtualenv/virtualenv-1.7.1.2.tar.gz &&
    tar zxf virtualenv-1.7.1.2.tar.gz &&
    cd virtualenv-1.7.1.2 &&
    ~/opt/python-$USEPY/bin/python$USEPY setup.py install
  )

  virtualenv --version
  which virtualenv
  # travis places its virtualenv in /usr/local/bin.
  # virtualenv 1.7 installed above for python 2.x goes in /usr/bin.
  # /usr/local/bin is earlier in path and takes precedence.
  # manually invoke the 1.7 version here.
  # however, when installed for 2.x our virtualenv 1.7 goes in /usr/local/bin.
  if test "$USEPY" = 3.1; then
    virtualenv=$HOME/opt/python-$USEPY/bin/virtualenv
  else
    virtualenv=/usr/bin/virtualenv
  fi
  $virtualenv --version
  $virtualenv ~/virtualenv/python$USEPY -p python$USEPY
  . ~/virtualenv/python$USEPY/bin/activate
  python -V
  which pip
  pip --version
fi

if test -e requirements-dev-$USEPY.txt; then
  pip install -r requirements-dev-$USEPY.txt
else
  pip install -r requirements-dev.txt
fi

if test "$USEPY" = 3.1; then
  # install flaky since pip/tarfile barfs on it
  wget_once https://pypi.python.org/packages/source/f/flaky/flaky-2.2.0.tar.gz
  tar xfz flaky-2.2.0.tar.gz
  cd flaky-2.2.0
  python setup.py install
  cd ..
fi

if test -n "$USECURL"; then
  if echo "$USECURL" |grep -q -- "-libssh2\$"; then
    curl_suffix=-libssh2
    USECURL=$(echo "$USECURL" |sed -e s/-libssh2//)
  else
    curl_suffix=
  fi
  if echo "$USECURL" |grep -q -- "-gssapi\$"; then
    curl_suffix=-gssapi$curl_suffix
    USECURL=$(echo "$USECURL" |sed -e s/-gssapi//)
  fi

  if test -n "$USEOPENSSL"; then
    (cd && mkdir -p opt && cd opt &&
      wget $file_host/openssl-"$USEOPENSSL"-$distro-64.tar.xz &&
      tar xfJ openssl-"$USEOPENSSL"-$distro-64.tar.xz)
  fi
  if test -n "$USELIBRESSL"; then
    (cd && mkdir -p opt && cd opt &&
      wget $file_host/libressl-"$USELIBRESSL"-$distro-64.tar.xz &&
      tar xfJ libressl-"$USELIBRESSL"-$distro-64.tar.xz)
  fi

  if test -n "$USESSL"; then
    if test "$USESSL" != none && ! echo "$USECURL" |grep -q "$USESSL"; then
      curldirname=curl-"$USECURL"-"$USESSL"$curl_suffix
    else
      curldirname=curl-"$USECURL"-none$curl_suffix
    fi
  else
    curldirname=curl-"$USECURL"$curl_suffix
  fi
  export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/opt/$curldirname/lib
  name=$curldirname-$distro-64.tar.xz
  (cd &&
    mkdir -p opt &&
    cd opt &&
    wget $file_host/"$name" &&
    tar xfJ "$name")
  curl_flavor=`echo "$USECURL" |awk -F- '{print $2}'`
  "$HOME"/opt/$curldirname/bin/curl -V
else
  curl -V
fi

if test -n "$USEPY"; then
  PYTHON_VERSION="$USEPY"
else
  PYTHON_VERSION="$TRAVIS_PYTHON_VERSION"
fi

# for building documentation.
# this must be done after python is installed so that we install sphinx
# into the correct python version.
# sphinx 1.4.9 requires python 2.6+ or 3.3+
# sphinx 1.5 requires python 2.7 or 3.4+
case "$PYTHON_VERSION" in
  2.[45])
    ;;
  2.6)
    pip install sphinx==1.4.9
    ;;
  3.[12])
    ;;
  3.3)
    pip install sphinx==1.4.9
    ;;
  *)
    pip install sphinx
    ;;
esac