Skip to content

Commit c070951

Browse files
committed
feat: add download script for pre-built library
Adds scripts/download-lib.sh to download pre-built libmlx from GitHub releases. Supports: - macOS ARM64 (Metal) - macOS x64 (CPU) - Linux x64 (CPU) - Linux ARM64 (CPU) - Windows x64 (CPU) Usage: ./scripts/download-lib.sh [version]
1 parent aabde77 commit c070951

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

scripts/download-lib.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/bin/bash
2+
# Download pre-built MLX library for Go bindings
3+
# Usage: ./scripts/download-lib.sh [version]
4+
5+
set -e
6+
7+
VERSION="${1:-latest}"
8+
REPO="luxfi/mlx"
9+
LIB_DIR="$(dirname "$0")/../lib"
10+
11+
# Detect platform
12+
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
13+
ARCH=$(uname -m)
14+
15+
case "$OS" in
16+
darwin)
17+
case "$ARCH" in
18+
arm64) PLATFORM="macos-arm64" ;;
19+
x86_64) PLATFORM="macos-x64" ;;
20+
*) echo "Unsupported macOS architecture: $ARCH"; exit 1 ;;
21+
esac
22+
;;
23+
linux)
24+
case "$ARCH" in
25+
x86_64) PLATFORM="linux-x64" ;;
26+
aarch64) PLATFORM="linux-arm64" ;;
27+
*) echo "Unsupported Linux architecture: $ARCH"; exit 1 ;;
28+
esac
29+
;;
30+
mingw*|msys*|cygwin*)
31+
PLATFORM="windows-x64"
32+
;;
33+
*)
34+
echo "Unsupported OS: $OS"
35+
exit 1
36+
;;
37+
esac
38+
39+
FILENAME="libmlx-${PLATFORM}.tar.gz"
40+
41+
echo "=== Downloading MLX library for $PLATFORM ==="
42+
mkdir -p "$LIB_DIR"
43+
44+
if [ "$VERSION" = "latest" ]; then
45+
URL="https://github.com/${REPO}/releases/latest/download/${FILENAME}"
46+
else
47+
URL="https://github.com/${REPO}/releases/download/${VERSION}/${FILENAME}"
48+
fi
49+
50+
echo "Downloading from: $URL"
51+
curl -fsSL "$URL" -o "/tmp/${FILENAME}" || {
52+
echo "Failed to download. Available releases:"
53+
echo " https://github.com/${REPO}/releases"
54+
exit 1
55+
}
56+
57+
echo "Extracting to: $LIB_DIR"
58+
tar -xzf "/tmp/${FILENAME}" -C "$LIB_DIR"
59+
rm "/tmp/${FILENAME}"
60+
61+
echo "=== MLX library installed successfully ==="
62+
ls -la "$LIB_DIR"

0 commit comments

Comments
 (0)