macos build works in CI

This commit is contained in:
geoffsee
2025-06-21 08:31:01 -04:00
parent 8e5d6fe5c8
commit 791eefaeec
4 changed files with 53 additions and 23 deletions

View File

@@ -10,13 +10,34 @@ env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
# Job for building on macOS (with Metal)
build-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v4
- name: Build
run: cargo build
- name: Run tests
run: cargo test
- uses: actions/checkout@v4
- name: Setup Python virtual environment
shell: bash
run: |
python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install --upgrade pip
python3 -m pip install huggingface-hub
- name: Login to HuggingFace Hub
env:
HF_TOKEN: ${{ secrets.HUGGINGFACE_TOKEN }}
run: |
source .venv/bin/activate
if [ -n "$HF_TOKEN" ]; then
echo "Logging into Hugging Face Hub..."
huggingface-cli login --token $HF_TOKEN
else
echo "No HuggingFace token found, skipping login"
fi
- uses: oven-sh/setup-bun@v2
- run: bun install
- name: Build (macOS - Metal)
# The `metal` feature will be automatically picked up due to target_os = "macos" in Cargo.toml
run: cargo build --release
- name: Run tests (macOS)
run: cargo test

12
Cargo.lock generated
View File

@@ -782,9 +782,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1980d53280c8f9e2c6cbe1785855d7ff8010208b46e21252b978badf13ad69d"
dependencies = [
"candle-core",
"candle-metal-kernels",
"half",
"metal 0.27.0",
"num-traits",
"rayon",
"safetensors",
@@ -1381,7 +1379,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cea14ef9355e3beab063703aa9dab15afd25f0667c341310c1e5274bb1d0da18"
dependencies = [
"libc",
"windows-sys 0.52.0",
"windows-sys 0.59.0",
]
[[package]]
@@ -2639,7 +2637,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07033963ba89ebaf1584d767badaa2e8fcec21aedea6b8c0346d487d49c28667"
dependencies = [
"cfg-if",
"windows-targets 0.52.6",
"windows-targets 0.53.0",
]
[[package]]
@@ -4313,7 +4311,7 @@ dependencies = [
"errno",
"libc",
"linux-raw-sys",
"windows-sys 0.52.0",
"windows-sys 0.59.0",
]
[[package]]
@@ -5106,7 +5104,7 @@ dependencies = [
"getrandom 0.3.3",
"once_cell",
"rustix",
"windows-sys 0.52.0",
"windows-sys 0.59.0",
]
[[package]]
@@ -5925,7 +5923,7 @@ version = "0.1.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf221c93e13a30d793f7645a0e7762c55d169dbb0a49671918a2319d289b10bb"
dependencies = [
"windows-sys 0.52.0",
"windows-sys 0.59.0",
]
[[package]]

View File

@@ -6,8 +6,8 @@ edition = "2021"
[dependencies]
accelerate-src = { version = "0.3.2", optional = true }
candle-datasets = { version = "=0.9.1", optional = true }
candle-nn = { version = "=0.9.1", features = ["metal"] }
candle-transformers = { version = "=0.9.1", features = ["metal"] }
candle-nn = { version = "=0.9.1" }
candle-transformers = { version = "=0.9.1" }
candle-flash-attn = { version = "=0.9.1", optional = true }
candle-onnx = { version = "=0.9.1", optional = true }
@@ -21,16 +21,15 @@ num-traits = { version = "0.2.15" }
palette = { version = "0.7.6", optional = true }
enterpolation = { version = "0.2.1", optional = true}
pyo3 = { version = "0.22.0", features = ["auto-initialize", "abi3-py311"], optional = true }
rayon = { version = "1.7.0" }
rayon = "1.7.0"
rubato = { version = "0.15.0", optional = true }
safetensors = { version = "0.4.1" }
safetensors = "0.4.1"
serde = { version = "1.0.171", features = ["derive"] }
serde_json = { version = "1.0.99" }
serde_json = "1.0.99"
symphonia = { version = "0.5.3", features = ["all"], optional = true }
tokenizers = { version = "0.21.0", default-features = false, features = ["onig", "http"] }
cpal = { version = "0.15.2", optional = true }
pdf2image = { version = "0.1.2" , optional = true}
candle-core = { version = "=0.9.1", features = ["metal"] }
anyhow = "1.0.98"
clap= { version = "4.2.4", features = ["derive"] }
tracing = "0.1.37"
@@ -45,6 +44,18 @@ utoipa = { version = "4.2.0", features = ["axum_extras"] }
uuid = { version = "1.7.0", features = ["v4"] }
reborrow = "0.5.5"
# --- Add this section for conditional compilation ---
[target.'cfg(target_os = "macos")'.dependencies]
candle-core = { version = "=0.9.1", features = ["metal"] }
[target.'cfg(not(target_os = "macos"))'.dependencies]
# For Linux or other non-macOS systems, you likely want the CPU backend or CUDA
# If you're building on Linux with a CUDA-enabled GPU:
candle-core = { version = "=0.9.1", features = ["cuda"], default-features = false } # Or just "cuda" if not using default features
# If you're building on Linux with only CPU:
# candle-core = { version = "=0.9.1", default-features = false } # CPU is often the default, but good to be explicit
# --- End of conditional compilation section ---
[dev-dependencies]
anyhow = { version = "1", features = ["backtrace"] }