forked from vllm-project/vllm-metal
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·164 lines (134 loc) · 3.95 KB
/
install.sh
File metadata and controls
executable file
·164 lines (134 loc) · 3.95 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/bin/bash
fetch_latest_release() {
local repo_owner="$1"
local repo_name="$2"
echo "Fetching latest release..." >&2
local latest_release_url="https://api.github.com/repos/${repo_owner}/${repo_name}/releases/latest"
local release_data
if ! release_data=$(curl -fsSL "$latest_release_url" 2>&1); then
error "Failed to fetch release information."
echo "Please check your internet connection and try again." >&2
exit 1
fi
if [[ -z "$release_data" ]] || [[ "$release_data" == *"Not Found"* ]]; then
error "No releases found for this repository."
echo "Please visit https://github.com/${repo_owner}/${repo_name}/releases" >&2
exit 1
fi
echo "$release_data"
}
extract_wheel_url() {
local release_data="$1"
python3 -c "
import sys
import json
try:
data = json.loads('''$release_data''')
assets = data.get('assets', [])
for asset in assets:
name = asset.get('name', '')
if name.endswith('.whl'):
print(asset.get('browser_download_url', ''))
break
except Exception as e:
print('', file=sys.stderr)
"
}
download_and_install_wheel() {
local wheel_url="$1"
local package_name="$2"
local wheel_name
wheel_name=$(basename "$wheel_url")
echo "Latest release: $wheel_name"
success "Found latest release"
local tmp_dir
tmp_dir=$(mktemp -d)
# shellcheck disable=SC2064
trap "rm -rf '$tmp_dir'" EXIT
echo ""
echo "Downloading wheel..."
local wheel_path="$tmp_dir/$wheel_name"
if ! curl -fsSL "$wheel_url" -o "$wheel_path"; then
error "Failed to download wheel."
exit 1
fi
success "Downloaded wheel"
# Install vllm-metal package
if ! uv pip install "$wheel_path"; then
error "Failed to install ${package_name}."
exit 1
fi
success "Installed ${package_name}"
}
main() {
set -eu -o pipefail
local repo_owner="vllm-project"
local repo_name="vllm-metal"
local package_name="vllm-metal"
# Source shared library functions
# Try local lib.sh first (when running ./install.sh), fall back to remote (when piped from curl)
local local_lib=""
if [[ -n "${BASH_SOURCE[0]:-}" ]]; then
local script_dir
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]:-}")" && pwd)"
local_lib="$script_dir/scripts/lib.sh"
fi
if [[ -n "$local_lib" && -f "$local_lib" ]]; then
# shellcheck source=/dev/null
source "$local_lib"
else
# Fetch from remote (curl | bash case)
local lib_url="https://raw.githubusercontent.com/$repo_owner/$repo_name/main/scripts/lib.sh"
local lib_tmp
lib_tmp=$(mktemp)
if ! curl -fsSL "$lib_url" -o "$lib_tmp"; then
echo "Error: Failed to fetch lib.sh from $lib_url" >&2
rm -f "$lib_tmp"
exit 1
fi
# shellcheck source=/dev/null
source "$lib_tmp"
rm -f "$lib_tmp"
fi
is_apple_silicon
if ! ensure_uv; then
exit 1
fi
local venv="$HOME/.venv-vllm-metal"
if [[ -n "$local_lib" && -f "$local_lib" ]]; then
venv="$PWD/.venv-vllm-metal"
fi
ensure_venv "$venv"
local vllm_v="0.14.1"
local url_base="https://github.com/vllm-project/vllm/releases/download"
local filename="vllm-$vllm_v.tar.gz"
curl -OL $url_base/v$vllm_v/$filename
tar xf $filename
cd vllm-$vllm_v
uv pip install -r requirements/cpu.txt --index-strategy unsafe-best-match
uv pip install .
cd -
rm -rf vllm-$vllm_v*
if [[ -n "$local_lib" && -f "$local_lib" ]]; then
uv pip install .
else
local release_data
release_data=$(fetch_latest_release "$repo_owner" "$repo_name")
local wheel_url
wheel_url=$(extract_wheel_url "$release_data")
if [[ -z "$wheel_url" ]]; then
error "No wheel file found in the latest release."
exit 1
fi
download_and_install_wheel "$wheel_url" "$package_name"
fi
echo ""
success "Installation complete!"
echo ""
echo "To use vllm, activate the virtual environment:"
echo " source $venv/bin/activate"
echo ""
echo "Or add the venv to your PATH:"
echo " export PATH=\"$venv/bin:\$PATH\""
}
main "$@"