blob: 5a4fcacde575652f46fc18b63e8cd49a12bfc826 [file] [log] [blame]
Joe Ethierfbe66152021-03-31 16:02:36 -07001#!/bin/bash
2
3# Copyright 2021 The Pigweed Authors
4#
5# Licensed under the Apache License, Version 2.0 (the "License"); you may not
6# use this file except in compliance with the License. You may obtain a copy of
7# the License at
8#
9# https://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14# License for the specific language governing permissions and limitations under
15# the License.
16
17set -o xtrace -o errexit -o nounset
18
19SRC="${BASH_SOURCE[0]}"
20DIR="$(python3 -c "import os; print(os.path.dirname(os.path.abspath(os.path.realpath(\"$SRC\"))))")"
21VENV="${DIR}/python-venv"
22PY_TO_TEST="python3"
23
24if [ ! -z "${1-}" ]; then
25 VENV="${1-}"
26 PY_TO_TEST="${VENV}/bin/python"
27fi
28
29PY_MAJOR_VERSION=$(${PY_TO_TEST} -c "import sys; print(sys.version_info[0])")
30PY_MINOR_VERSION=$(${PY_TO_TEST} -c "import sys; print(sys.version_info[1])")
31
32if [ ${PY_MAJOR_VERSION} -ne 3 ] || [ ${PY_MINOR_VERSION} -lt 7 ]
33then
34 echo "ERROR: This Python distributable requires Python 3.7 or newer."
35 exit 1
36fi
37
38if [ ! -d "${VENV}" ]
39then
40 ${PY_TO_TEST} -m venv ${VENV}
41fi
42
43${VENV}/bin/python -m pip install --upgrade pip
44
45for wheel in $(ls ${DIR}/python_wheels/*.whl)
46do
47 ${VENV}/bin/python -m pip install \
48 --upgrade --force-reinstall \
49 --find-links=${DIR}/python_wheels \
50 $wheel
51done
52
53exit 0