mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2024-11-30 21:54:16 +08:00
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>
This commit is contained in:
parent
01d15d8a38
commit
69ec13b303
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user