VirtualBox

source: vbox/trunk/src/VBox/Additions/3D/mesa/mesa-24.0.2/bin/python-venv.sh@ 106061

最後變更 在這個檔案從106061是 103996,由 vboxsync 提交於 11 月 前

Additions/3D/mesa: export mesa-24.0.2 to OSE. bugref:10606

檔案大小: 1.2 KB
 
1#!/usr/bin/env bash
2set -eu
3
4readonly requirements_file=$1
5shift
6
7venv_dir="$(dirname "$requirements_file")"/.venv
8readonly venv_dir
9readonly venv_req=$venv_dir/requirements.txt
10readonly venv_python_version=$venv_dir/python-version.txt
11
12if [ -d "$venv_dir" ]
13then
14 if [ ! -r "$venv_python_version" ]
15 then
16 echo "Python environment predates Python version checks."
17 echo "It might be invalid and needs to be regenerated."
18 rm -rf "$venv_dir"
19 elif ! cmp --quiet <(python --version) "$venv_python_version"
20 then
21 old=$(cat "$venv_python_version")
22 new=$(python --version)
23 echo "Python version has changed ($old -> $new)."
24 echo "Python environment needs to be regenerated."
25 unset old new
26 rm -rf "$venv_dir"
27 fi
28fi
29
30if ! [ -r "$venv_dir/bin/activate" ]
31then
32 echo "Creating Python environment..."
33 python -m venv "$venv_dir"
34 python --version > "$venv_python_version"
35fi
36
37# shellcheck disable=1091
38source "$venv_dir/bin/activate"
39
40if ! cmp --quiet "$requirements_file" "$venv_req"
41then
42 echo "$(realpath --relative-to="$PWD" "$requirements_file") has changed, re-installing..."
43 pip --disable-pip-version-check install --requirement "$requirements_file"
44 cp "$requirements_file" "$venv_req"
45fi
46
47python "$@"
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette