diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index edbccd5..67e1495 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -84,6 +84,6 @@ jobs: - name: Install libclang run: sudo apt-get update && sudo apt-get install -y libclang-dev clang - name: Regenerate bindings - run: cargo build -p dlpack-sys --features bindgen + run: cargo build --features bindgen - name: Check committed bindings are up to date - run: git diff --exit-code dlpack-sys/src/bindings.rs + run: git diff --exit-code src/bindings.rs diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..4232000 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,38 @@ +name: Release + +on: + workflow_dispatch: + inputs: + confirm: + description: 'Type "publish" to confirm — this publishes dlpack-rs to crates.io and is irreversible' + required: true + default: '' + +permissions: + contents: read + +jobs: + publish: + name: cargo publish dlpack-rs + runs-on: ubuntu-latest + steps: + - name: Guard — require explicit confirmation + env: + CONFIRM: ${{ inputs.confirm }} + run: | + if [ "$CONFIRM" != "publish" ]; then + echo "::error::Confirmation field must be exactly 'publish' (got: '$CONFIRM')" + echo "::error::This workflow publishes to crates.io and is irreversible." + exit 1 + fi + + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + + - name: cargo publish --dry-run + run: cargo publish --dry-run + + - name: cargo publish + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} + run: cargo publish diff --git a/Cargo.lock b/Cargo.lock index 486963d..4c3b289 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -65,17 +65,10 @@ dependencies = [ [[package]] name = "dlpack-rs" -version = "0.3.2" -dependencies = [ - "dlpack-sys", - "pyo3", -] - -[[package]] -name = "dlpack-sys" -version = "0.3.2" +version = "0.3.3" dependencies = [ "bindgen", + "pyo3", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 5d0f815..6396e6a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,19 +1,26 @@ -[workspace] -members = [".", "dlpack-sys"] -resolver = "2" - [package] name = "dlpack-rs" description = "Portable Rust bindings for the DLPack protocol (FFI + safe wrappers + optional pyo3 glue)" repository = "https://github.com/kornia/dlpack-rs" -version = "0.3.2" +version = "0.3.3" license = "Apache-2.0" edition = "2021" +[lib] +# The bindgen-generated bindings carry DLPack's C doc comments; some contain +# fenced blocks that rustdoc would treat as (failing) doctests. No real +# doctests in this crate. +doctest = false + [features] default = [] pyo3 = ["dep:pyo3"] +# Regenerate src/bindings.rs from vendor/dlpack/dlpack.h (needs libclang). +# Default builds use the committed bindings — no libclang required. +bindgen = ["dep:bindgen"] [dependencies] -dlpack-sys = { path = "dlpack-sys", version = "0.3.2" } pyo3 = { version = "0.28", optional = true } + +[build-dependencies] +bindgen = { version = "0.71", optional = true } diff --git a/dlpack-sys/build.rs b/build.rs similarity index 100% rename from dlpack-sys/build.rs rename to build.rs diff --git a/dlpack-sys/Cargo.toml b/dlpack-sys/Cargo.toml deleted file mode 100644 index ece2e3a..0000000 --- a/dlpack-sys/Cargo.toml +++ /dev/null @@ -1,19 +0,0 @@ -[package] -name = "dlpack-sys" -version = "0.3.2" -edition = "2021" -description = "Auto-generated FFI bindings for DLPack (dmlc/dlpack v1.3) via bindgen" -license = "Apache-2.0" -repository = "https://github.com/kornia/dlpack-rs" -links = "dlpack" - -[lib] -doctest = false - -[build-dependencies] -bindgen = { version = "0.71", optional = true } - -[features] -# default build uses the committed src/bindings.rs (no libclang needed) -default = [] -bindgen = ["dep:bindgen"] diff --git a/dlpack-sys/src/bindings.rs b/src/bindings.rs similarity index 100% rename from dlpack-sys/src/bindings.rs rename to src/bindings.rs diff --git a/src/ffi.rs b/src/ffi.rs index adb4d2d..9f3598c 100644 --- a/src/ffi.rs +++ b/src/ffi.rs @@ -1,7 +1,7 @@ -//! Re-export of auto-generated DLPack FFI bindings from `dlpack-sys`. +//! Re-export of auto-generated DLPack FFI bindings from the inlined `sys` module. //! The bindgen-generated types replace the former hand-written structs. #[allow(unused_imports)] -pub use dlpack_sys::*; +pub use crate::sys::*; // ── Stable public aliases ────────────────────────────────────────────────────── // These insulate consumers from bindgen naming (DLDeviceType::kDLCPU, etc.) and @@ -30,7 +30,7 @@ pub const K_DL_FLOAT: u8 = DLDataTypeCode::kDLFloat as u8; pub const K_DL_BOOL: u8 = DLDataTypeCode::kDLBool as u8; /// Read-only bitmask for `DLManagedTensorVersioned::flags` (u64). -pub const DLPACK_FLAG_BITMASK_READ_ONLY: u64 = dlpack_sys::DLPACK_FLAG_BITMASK_READ_ONLY as u64; +pub const DLPACK_FLAG_BITMASK_READ_ONLY: u64 = crate::sys::DLPACK_FLAG_BITMASK_READ_ONLY as u64; /// Is-copied bitmask for `DLManagedTensorVersioned::flags` (u64). -pub const DLPACK_FLAG_BITMASK_IS_COPIED: u64 = dlpack_sys::DLPACK_FLAG_BITMASK_IS_COPIED as u64; +pub const DLPACK_FLAG_BITMASK_IS_COPIED: u64 = crate::sys::DLPACK_FLAG_BITMASK_IS_COPIED as u64; diff --git a/src/lib.rs b/src/lib.rs index 9224252..5f1469f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,3 +4,4 @@ pub mod ffi; #[cfg(feature = "pyo3")] pub mod pyo3_glue; pub mod safe; +mod sys; diff --git a/dlpack-sys/src/lib.rs b/src/sys.rs similarity index 59% rename from dlpack-sys/src/lib.rs rename to src/sys.rs index 60d98a4..0d612af 100644 --- a/dlpack-sys/src/lib.rs +++ b/src/sys.rs @@ -1,9 +1,15 @@ +//! Auto-generated DLPack FFI bindings (rust-bindgen from `vendor/dlpack/dlpack.h`). +//! +//! Formerly the separate `dlpack-rs-sys` crate; inlined here so `dlpack-rs` +//! publishes to crates.io as a single crate (no sys crate to publish). +//! Regenerate `bindings.rs` with `--features bindgen` (needs libclang). #![allow( non_upper_case_globals, non_camel_case_types, non_snake_case, dead_code )] + include!("bindings.rs"); #[cfg(test)] diff --git a/dlpack-sys/vendor/dlpack/VENDOR.md b/vendor/dlpack/VENDOR.md similarity index 100% rename from dlpack-sys/vendor/dlpack/VENDOR.md rename to vendor/dlpack/VENDOR.md diff --git a/dlpack-sys/vendor/dlpack/dlpack.h b/vendor/dlpack/dlpack.h similarity index 100% rename from dlpack-sys/vendor/dlpack/dlpack.h rename to vendor/dlpack/dlpack.h