Merge "Python 3.5 and python2 tox in Ubuntu 16.04"
[releng/global-jjb.git] / shell / tox-install.sh
1 #!/bin/bash -l
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2017 The Linux Foundation and others.
5 #
6 # All rights reserved. This program and the accompanying materials
7 # are made available under the terms of the Eclipse Public License v1.0
8 # which accompanies this distribution, and is available at
9 # http://www.eclipse.org/legal/epl-v10.html
10 ##############################################################################
11 echo "---> tox-install.sh"
12
13 # Ensure we fail the job if any steps fail or variables are missing.
14 # Use -x to show value of $PYTHON in output
15 set -eux -o pipefail
16
17 #Python 3.5 and python2 tox in Ubuntu 16.04 workaround
18 done="False"
19 if [[ -f /etc/lsb-release ]]; then
20    # shellcheck disable=SC1091
21    source /etc/lsb-release
22    if [[ $DISTRIB_RELEASE == "16.04" ]]; then
23        echo "WARNING: Python projects should move to Ubuntu 18.04 to continue receiving support"
24        python2 -m pip install --user --quiet --upgrade tox tox-pyenv virtualenv more-itertools~=5.0.0
25        python3 -m pip install --user --quiet --upgrade tox tox-pyenv virtualenv zipp==1.1.0
26        done="True"
27    fi
28 fi
29
30 if [[ $done != "True" ]]; then
31     if [[ $PYTHON == "python2" ]]; then
32         $PYTHON -m pip install --user --quiet --upgrade tox tox-pyenv virtualenv more-itertools~=5.0.0
33     else
34         $PYTHON -m pip install --user --quiet --upgrade tox tox-pyenv virtualenv
35     fi
36 fi
37
38 # installs are silent, show version details in log
39 $PYTHON --version
40 $PYTHON -m pip --version
41 $PYTHON -m pip freeze