Fix: Install lftools before other packages
[releng/global-jjb.git] / shell / python-tools-install.sh
1 #!/bin/bash
2 # SPDX-License-Identifier: EPL-1.0
3 ##############################################################################
4 # Copyright (c) 2018 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 "---> python-tools-install.sh"
12
13 set -eufo pipefail
14
15 # This script will typically be called during pre-build & post-build.
16 # Create the user venv during pre-build.
17 if [[ ! -f /tmp/pre-build-complete ]]; then
18     requirements_file=$(mktemp /tmp/requirements-XXXXXX)
19
20     # Note: To test lftools master branch change the lftools configuration below in
21     #       the requirements file from "lftools[openstack]~=#.##.#" to
22     #       git+https://github.com/lfit/releng-lftools.git#egg=lftools[openstack]
23
24     echo "Generating Requirements File"
25     cat << 'EOF' > "$requirements_file"
26 python-heatclient
27 python-openstackclient
28 python-magnumclient
29 kubernetes
30 niet~=1.4.2
31 cryptography<3.4
32 yq
33
34 # PINNED INDIRECT DEPENDENCIES
35 # ============================
36 # The libraries listed below should be considered workarounds and thus need
37 # to have a link to a JIRA and any relevant pkg versions and support packages
38 # necessary so that future maintainers of this file can make decisions to
39 # remove the workarounds in the future.
40 importlib-resources<2.0.0  # virtualenv 20.0.21 requires importlib-resources<2.0.0 (RELENG-2993)
41 EOF
42
43     #Python 3.5 in Ubuntu 16.04 workaround
44     if [[ -f /etc/lsb-release ]]; then
45         # shellcheck disable=SC1091
46         source /etc/lsb-release
47         if [[ $DISTRIB_RELEASE == "16.04" && $DISTRIB_ID == "Ubuntu" ]]; then
48             echo "WARNING: Python projects should move to Ubuntu 18.04 to continue receiving support"
49             echo "zipp==1.1.0" >> "$requirements_file"
50         fi
51     fi
52
53     python3 -m pip install --user --quiet --upgrade pip
54     python3 -m pip install --user --quiet --no-warn-script-location --upgrade setuptools
55     python3 -m pip install --user --quiet --no-warn-script-location --upgrade lftools[openstack]
56     python3 -m pip install --user --quiet --no-warn-script-location --upgrade \
57         --upgrade-strategy eager -r "$requirements_file"
58     # installs are silent, show version details in log
59     python3 --version
60     python3 -m pip --version
61     python3 -m pip freeze
62
63     rm -rf "$requirements_file"
64     touch /tmp/pre-build-complete
65 fi