aboutsummaryrefslogtreecommitdiff
path: root/pw_build/python_dist/setup.sh
diff options
context:
space:
mode:
authorAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-03-12 23:07:32 +0000
committerAndroid Build Coastguard Worker <android-build-coastguard-worker@google.com>2024-03-12 23:07:32 +0000
commit47562fa92998f8f4289ae9a8048349067754d52e (patch)
treec1643be8ab17fc607cea748a8bb1d621a5964873 /pw_build/python_dist/setup.sh
parenteeec55b65fe2c3c7647bb70ea44b3c839eb1267c (diff)
parent646563934a3e2ee26f50171f94d95173a1662e2c (diff)
downloadpigweed-47562fa92998f8f4289ae9a8048349067754d52e.tar.gz
Snap for 11566117 from 646563934a3e2ee26f50171f94d95173a1662e2c to sdk-releaseplatform-tools-35.0.1
Change-Id: Iec629b181a2c6905754a4c340e334884e13fd3b4
Diffstat (limited to 'pw_build/python_dist/setup.sh')
-rwxr-xr-xpw_build/python_dist/setup.sh35
1 files changed, 14 insertions, 21 deletions
diff --git a/pw_build/python_dist/setup.sh b/pw_build/python_dist/setup.sh
index 81ddb5d1a..56b136c6b 100755
--- a/pw_build/python_dist/setup.sh
+++ b/pw_build/python_dist/setup.sh
@@ -21,6 +21,7 @@ DIR="$(python3 -c "import os; print(os.path.dirname(os.path.abspath(os.path.real
VENV="${DIR}/python-venv"
PY_TO_TEST="python3"
CONSTRAINTS_PATH="${DIR}/constraints.txt"
+EXTRA_REQUIREMENT_PATH="${DIR}/python_wheels/requirements.txt"
if [ ! -z "${1-}" ]; then
VENV="${1-}"
@@ -29,15 +30,20 @@ fi
CONSTRAINTS_ARG=""
if [ -f "${CONSTRAINTS_PATH}" ]; then
- CONSTRAINTS_ARG="-c""${CONSTRAINTS_PATH}"
+ CONSTRAINTS_ARG="-c ""${CONSTRAINTS_PATH}"
+fi
+
+EXTRA_REQUIREMENT_ARG=""
+if [ -f "${EXTRA_REQUIREMENT_PATH}" ]; then
+ EXTRA_REQUIREMENT_ARG="-r ""${EXTRA_REQUIREMENT_PATH}"
fi
PY_MAJOR_VERSION=$(${PY_TO_TEST} -c "import sys; print(sys.version_info[0])")
PY_MINOR_VERSION=$(${PY_TO_TEST} -c "import sys; print(sys.version_info[1])")
-if [ ${PY_MAJOR_VERSION} -ne 3 ] || [ ${PY_MINOR_VERSION} -lt 7 ]
+if [ ${PY_MAJOR_VERSION} -ne 3 ] || [ ${PY_MINOR_VERSION} -lt 8 ]
then
- echo "ERROR: This Python distributable requires Python 3.7 or newer."
+ echo "ERROR: This Python distributable requires Python 3.8 or newer."
exit 1
fi
@@ -46,23 +52,10 @@ then
${PY_TO_TEST} -m venv "${VENV}"
fi
-"${VENV}/bin/python" -m pip install --upgrade pip
-
-# Uninstall wheels first, in case installing over an existing venv. This is a
-# faster and less destructive approach than --force-reinstall to ensure wheels
-# whose version numbers haven't incremented still get reinstalled.
-IFS_BACKUP="$IFS"
-IFS=$'\n'
-for wheel in $(ls "${DIR}/python_wheels/"*.whl)
-do
- "${VENV}/bin/python" -m pip uninstall --yes "$wheel"
-done
-
-for wheel in $(ls "${DIR}/python_wheels/"*.whl)
-do
- "${VENV}/bin/python" -m pip install \
- --upgrade --find-links="${DIR}/python_wheels" ${CONSTRAINTS_ARG} "$wheel"
-done
-IFS="$IFS_BACKUP"
+# Note: pip install --require-hashes will be triggered if any hashes are present
+# in the requirement.txt file.
+"${VENV}/bin/python" -m pip install \
+ --find-links="${DIR}/python_wheels" \
+ -r ${DIR}/requirements.txt ${EXTRA_REQUIREMENT_ARG} ${CONSTRAINTS_ARG}
exit 0