2024-04-20 11:08:01 +08:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
|
|
|
|
if [ "$(id -u)" -ne 0 ]; then
|
|
|
|
echo "Please run as root" >&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2024-06-16 22:54:56 +08:00
|
|
|
python_package="python3.12"
|
2024-04-20 11:08:01 +08:00
|
|
|
venv=".env-linux"
|
|
|
|
reqs_file="requirements.txt"
|
|
|
|
script_dir=$( cd -- "$( dirname -- "${0}" )" &> /dev/null && pwd )
|
|
|
|
|
2024-06-16 22:54:56 +08:00
|
|
|
apt update -y || exit 1
|
|
|
|
apt install software-properties-common -y
|
2024-04-20 11:08:01 +08:00
|
|
|
add-apt-repository ppa:deadsnakes/ppa -y
|
|
|
|
apt update -y || exit 1
|
|
|
|
apt install "$python_package" -y || exit 1
|
2024-06-16 22:54:56 +08:00
|
|
|
apt install "$python_package-dev" -y || exit 1
|
2024-04-20 11:08:01 +08:00
|
|
|
apt install "$python_package-venv" -y || exit 1
|
2024-06-16 22:54:56 +08:00
|
|
|
apt install python3-dev -y || exit 1
|
2024-04-20 11:08:01 +08:00
|
|
|
|
|
|
|
[[ -d "$script_dir/$venv" ]] && rm -r -f "$script_dir/$venv"
|
|
|
|
|
|
|
|
$python_package -m venv "$script_dir/$venv" || exit 1
|
|
|
|
sleep 1
|
|
|
|
|
|
|
|
chmod 777 "$script_dir/$venv/bin/activate"
|
|
|
|
source "$script_dir/$venv/bin/activate"
|
|
|
|
|
|
|
|
pip install -r "$script_dir/$reqs_file"
|
|
|
|
exit_code=$?
|
|
|
|
|
|
|
|
deactivate
|
|
|
|
exit $exit_code
|