Improve python-tools-install.sh alpine compat
[releng/global-jjb.git] / shell / tox-install.sh
index 17bebec..0434b3a 100644 (file)
@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/bin/bash -l
 # SPDX-License-Identifier: EPL-1.0
 ##############################################################################
 # Copyright (c) 2017 The Linux Foundation and others.
 ##############################################################################
 echo "---> tox-install.sh"
 
-# Ensure we fail the job if any steps fail.
-# DO NOT set -u as virtualenv's activate script has unbound variables
-set -e -o pipefail
+# Ensure we fail the job if any steps fail or variables are missing.
+# Use -x to show value of $PYTHON in output
+set -eux -o pipefail
 
-virtualenv --quiet "/tmp/v/tox"
-# shellcheck source=/tmp/v/tox/bin/activate disable=SC1091
-source "/tmp/v/tox/bin/activate"
-pip install --quiet --upgrade pip
-pip install --quiet --upgrade pipdeptree
-pip install --quiet --upgrade tox argparse
+#Python 3.5 and python2 tox in Ubuntu 16.04 workaround
+done="False"
+if [[ -f /etc/lsb-release ]]; then
+   # shellcheck disable=SC1091
+   source /etc/lsb-release
+   if [[ $DISTRIB_RELEASE == "16.04" ]]; then
+       echo "WARNING: Python projects should move to Ubuntu 18.04 to continue receiving support"
+       python2 -m pip install --user --quiet --upgrade tox tox-pyenv virtualenv more-itertools~=5.0.0
+       python3 -m pip install --user --quiet --upgrade tox tox-pyenv virtualenv zipp==1.1.0
+       done="True"
+   fi
+fi
 
-echo "----> Pip Dependency Tree"
-pipdeptree
+if [[ $done != "True" ]]; then
+        python -m pip install --user --quiet --upgrade tox tox-pyenv virtualenv more-itertools~=5.0.0
+        python3 -m pip install --user --quiet --upgrade tox tox-pyenv virtualenv
+fi
+
+# installs are silent, show version details in log
+$PYTHON --version
+$PYTHON -m pip --version
+$PYTHON -m pip freeze