aboutsummaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorEric Engestrom <eric@igalia.com>2023-11-24 16:43:30 +0000
committerMarge Bot <emma+marge@anholt.net>2023-11-30 08:39:17 +0000
commit69ec13b303a8781148aaaee74fb6b05227ed783c (patch)
tree7a721f9a8b7b67b27043fc16c50f6080041c48e0 /bin
parent01d15d8a38b02330945de2d2240cdff353ad0bc0 (diff)
downloadmesa3d-69ec13b303a8781148aaaee74fb6b05227ed783c.tar.gz
bin/python-venv: detect python version change
The venv only works for a specific python version; when updating python, the venv needs to be regenerated. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/26354>
Diffstat (limited to 'bin')
-rwxr-xr-xbin/python-venv.sh17
1 files changed, 17 insertions, 0 deletions
diff --git a/bin/python-venv.sh b/bin/python-venv.sh
index 2c4f6dccdbe..b6cf7fd9f5b 100755
--- a/bin/python-venv.sh
+++ b/bin/python-venv.sh
@@ -7,11 +7,28 @@ shift
venv_dir="$(dirname "$requirements_file")"/.venv
readonly venv_dir
readonly venv_req=$venv_dir/requirements.txt
+readonly venv_python_version=$venv_dir/python-version.txt
+
+if [ -d "$venv_dir" ] && [ ! -r "$venv_python_version" ]
+then
+ echo "Python environment predates Python version checks."
+ echo "It might be invalid and needs to be regenerated."
+ rm -rf "$venv_dir"
+elif ! cmp --quiet <(python --version) "$venv_python_version"
+then
+ old=$(cat "$venv_python_version")
+ new=$(python --version)
+ echo "Python version has changed ($old -> $new)."
+ echo "Python environment needs to be regenerated."
+ unset old new
+ rm -rf "$venv_dir"
+fi
if ! [ -r "$venv_dir/bin/activate" ]
then
echo "Creating Python environment..."
python -m venv "$venv_dir"
+ python --version > "$venv_python_version"
fi
# shellcheck disable=1091