-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathinstall_uv_python.sh
More file actions
65 lines (55 loc) · 1.21 KB
/
install_uv_python.sh
File metadata and controls
65 lines (55 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
set -euxo pipefail
# Variables
PREFIX=/opt/jab
SYSTEM_PYTHON=/usr/bin/python3
# Functions
in_tmp_dir() {
(
cd "$(mktemp -d)"
"$@"
rm -rf "$(readlink -f .)"
)
}
detect_arch() {
uname -m
}
uv_url() {
local arch
arch=$(detect_arch)
case "$arch" in
x86_64)
echo "https://github.com/astral-sh/uv/releases/latest/download/uv-x86_64-apple-darwin.tar.gz"
;;
arm64)
echo "https://github.com/astral-sh/uv/releases/latest/download/uv-aarch64-apple-darwin.tar.gz"
;;
*)
echo "❌ Unsupported architecture: $arch" >&2
exit 1
;;
esac
}
pull_uv_to() {
local target_dir="$1"
mkdir -p "$target_dir"
local url
url=$(uv_url)
curl -L "$url" | tar -xz
mv uv "$target_dir/uv"
chmod +x "$target_dir/uv"
}
install_python() {
"$SYSTEM_PYTHON" -m venv "$PREFIX/python"
}
make_symlinks() {
ln -sf "$PREFIX/venv/bin/python" "$PREFIX/bin/python"
ln -sf "$PREFIX/venv/bin/pip" "$PREFIX/bin/pip"
}
main() {
in_tmp_dir pull_uv_to "$PREFIX/bin"
install_python
make_symlinks
echo "✅ Bootstrapped uv and Python into $PREFIX"
}
main "$@"