From 0f81c89ea8ec2793e3a7a21d586b8f679d9635ee Mon Sep 17 00:00:00 2001 From: kerthcet Date: Sun, 30 Aug 2026 12:31:40 +0100 Subject: [PATCH] release v0.0.1 Signed-off-by: kerthcet --- .gitmodules | 2 +- README.md | 10 +++++++--- crates/mlxcore-sys/Cargo.toml | 2 ++ crates/mlxcore-sys/build.rs | 11 ++++++++--- {third_party => crates/mlxcore-sys/third_party}/mlx-c | 0 crates/mlxcore/Cargo.toml | 3 +++ crates/mlxcore/examples/hello.rs | 2 +- crates/mlxcore/examples/relu.rs | 2 +- 8 files changed, 23 insertions(+), 9 deletions(-) rename {third_party => crates/mlxcore-sys/third_party}/mlx-c (100%) diff --git a/.gitmodules b/.gitmodules index b3738cd..601d3ef 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ [submodule "third_party/mlx-c"] - path = third_party/mlx-c + path = crates/mlxcore-sys/third_party/mlx-c url = https://github.com/ml-explore/mlx-c.git diff --git a/README.md b/README.md index d96dc0f..5a23861 100644 --- a/README.md +++ b/README.md @@ -39,14 +39,18 @@ The bindings are layered, the same way as [MLX Swift](https://github.com/ml-expl ``` mlxcore (safe, idiomatic Rust API) <- crates/mlxcore mlxcore-sys (raw unsafe FFI bindings) <- crates/mlxcore-sys, generated by bindgen -mlx-c (Apple's C API for MLX) <- third_party/mlx-c (git submodule) -mlx (Apple's C++ framework) <- fetched by mlx-c's CMake build +mlx-c (Apple's C API for MLX) <- crates/mlxcore-sys/third_party/mlx-c (git submodule) +mlx (Apple's C++ framework) <- fetched by mlx-c's CMake build ``` MLX itself is C++, which Rust cannot bind to directly. We bind against [`mlx-c`](https://github.com/ml-explore/mlx-c), Apple's official C API, whose CMake build pulls in MLX via `FetchContent`. +The mlx-c submodule sits inside `mlxcore-sys` rather than at the repository root +because `cargo package` only ships files under the crate directory — from the +root it would be missing from the published crate. + ## Building from source ```sh @@ -64,7 +68,7 @@ Runnable examples live in `crates/mlxcore/examples`: ```sh cargo run --example hello # arrays, shapes, streams -cargo run --example linear # y = relu(x @ W + b) with random weights +cargo run --example relu # y = relu(x @ W + b) with random weights ``` ## Note: suffix float literals with `f32` diff --git a/crates/mlxcore-sys/Cargo.toml b/crates/mlxcore-sys/Cargo.toml index e6f027b..53ec04a 100644 --- a/crates/mlxcore-sys/Cargo.toml +++ b/crates/mlxcore-sys/Cargo.toml @@ -8,6 +8,8 @@ license.workspace = true repository.workspace = true authors.workspace = true description = "Low-level FFI bindings to mlx-c, the C API for Apple's MLX framework." +keywords = ["mlx", "apple", "metal", "ffi", "bindings"] +categories = ["external-ffi-bindings"] links = "mlxc" build = "build.rs" diff --git a/crates/mlxcore-sys/build.rs b/crates/mlxcore-sys/build.rs index 40e310c..9a36dfb 100644 --- a/crates/mlxcore-sys/build.rs +++ b/crates/mlxcore-sys/build.rs @@ -17,11 +17,16 @@ fn main() { } let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); - // Workspace layout: /crates/mlxcore-sys -> /third_party/mlx-c + // mlx-c lives *inside* this crate rather than at the workspace root, because + // `cargo package` only ships files under the crate directory. A path that + // escaped upwards would build here and then fail for anyone installing from + // crates.io. let mlx_c_dir = manifest_dir - .join("../../third_party/mlx-c") + .join("third_party/mlx-c") .canonicalize() - .expect("third_party/mlx-c submodule not found — run `git submodule update --init`"); + .expect( + "third_party/mlx-c submodule not found — run `git submodule update --init --recursive`", + ); // --- 1. Build mlx-c (+ MLX via FetchContent) with CMake --------------- let mut cfg = cmake::Config::new(&mlx_c_dir); diff --git a/third_party/mlx-c b/crates/mlxcore-sys/third_party/mlx-c similarity index 100% rename from third_party/mlx-c rename to crates/mlxcore-sys/third_party/mlx-c diff --git a/crates/mlxcore/Cargo.toml b/crates/mlxcore/Cargo.toml index f6a5e84..d2373fa 100644 --- a/crates/mlxcore/Cargo.toml +++ b/crates/mlxcore/Cargo.toml @@ -6,6 +6,9 @@ license.workspace = true repository.workspace = true authors.workspace = true description = "Safe, idiomatic Rust bindings for Apple's MLX array framework." +readme = "../../README.md" +keywords = ["mlx", "apple", "metal", "array", "machine-learning"] +categories = ["api-bindings", "mathematics"] [features] default = ["metal", "accelerate"] diff --git a/crates/mlxcore/examples/hello.rs b/crates/mlxcore/examples/hello.rs index f2eb89e..9094482 100644 --- a/crates/mlxcore/examples/hello.rs +++ b/crates/mlxcore/examples/hello.rs @@ -1,7 +1,7 @@ //! A tour of the `mlxcore` API: constructors, arithmetic, reductions, shape //! manipulation, comparisons, and stream control. //! -//! For a worked end-to-end computation, see `examples/linear.rs`. +//! For a worked end-to-end computation, see `examples/relu.rs`. //! //! Run with: //! ```sh diff --git a/crates/mlxcore/examples/relu.rs b/crates/mlxcore/examples/relu.rs index cbc8435..bc06836 100644 --- a/crates/mlxcore/examples/relu.rs +++ b/crates/mlxcore/examples/relu.rs @@ -2,7 +2,7 @@ //! //! Run with: //! ```sh -//! cargo run --example linear +//! cargo run --example relu //! ``` use mlxcore::{Array, Stream, random};