2022-12-01 07:11:26 +08:00
|
|
|
#!/usr/bin/env bash
|
2022-01-08 07:15:18 +08:00
|
|
|
set -e
|
2020-01-18 02:22:00 +08:00
|
|
|
|
2024-06-19 02:27:28 +08:00
|
|
|
# Increase the pip timeout to handle TimeoutError
|
|
|
|
export PIP_DEFAULT_TIMEOUT=200
|
|
|
|
|
2022-01-03 06:47:16 +08:00
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
|
2024-10-14 00:55:06 +08:00
|
|
|
ROOT="$DIR"/../
|
|
|
|
cd "$ROOT"
|
2022-01-03 06:47:16 +08:00
|
|
|
|
2024-06-28 11:29:11 +08:00
|
|
|
# updating uv on macOS results in 403 sometimes
|
|
|
|
function update_uv() {
|
|
|
|
for i in $(seq 1 5);
|
|
|
|
do
|
|
|
|
if uv self update; then
|
|
|
|
return 0
|
|
|
|
else
|
|
|
|
sleep 2
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
echo "Failed to update uv 5 times!"
|
|
|
|
}
|
|
|
|
|
2024-06-28 08:04:05 +08:00
|
|
|
if ! command -v "uv" > /dev/null 2>&1; then
|
|
|
|
echo "installing uv..."
|
|
|
|
curl -LsSf https://astral.sh/uv/install.sh | sh
|
2024-11-10 14:16:41 +08:00
|
|
|
UV_BIN="$HOME/.local/bin"
|
|
|
|
PATH="$UV_BIN:$PATH"
|
2024-05-27 12:21:50 +08:00
|
|
|
fi
|
2020-10-22 02:36:18 +08:00
|
|
|
|
2024-06-28 08:47:13 +08:00
|
|
|
echo "updating uv..."
|
2024-06-28 11:29:11 +08:00
|
|
|
update_uv
|
2024-06-28 08:47:13 +08:00
|
|
|
|
2024-06-28 08:04:05 +08:00
|
|
|
echo "installing python packages..."
|
2024-08-15 03:11:39 +08:00
|
|
|
uv sync --frozen --all-extras
|
2024-06-28 08:04:05 +08:00
|
|
|
source .venv/bin/activate
|
2022-01-03 06:47:16 +08:00
|
|
|
|
2024-10-14 00:55:06 +08:00
|
|
|
echo "PYTHONPATH=${PWD}" > "$ROOT"/.env
|
2023-08-22 04:30:48 +08:00
|
|
|
if [[ "$(uname)" == 'Darwin' ]]; then
|
2024-10-14 00:55:06 +08:00
|
|
|
echo "# msgq doesn't work on mac" >> "$ROOT"/.env
|
|
|
|
echo "export ZMQ=1" >> "$ROOT"/.env
|
|
|
|
echo "export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES" >> "$ROOT"/.env
|
2023-08-22 04:30:48 +08:00
|
|
|
fi
|