Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
38 changes: 38 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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
11 changes: 2 additions & 9 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 13 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 }
File renamed without changes.
19 changes: 0 additions & 19 deletions dlpack-sys/Cargo.toml

This file was deleted.

File renamed without changes.
8 changes: 4 additions & 4 deletions src/ffi.rs
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ pub mod ffi;
#[cfg(feature = "pyo3")]
pub mod pyo3_glue;
pub mod safe;
mod sys;
6 changes: 6 additions & 0 deletions dlpack-sys/src/lib.rs → src/sys.rs
Original file line number Diff line number Diff line change
@@ -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)]
Expand Down
File renamed without changes.
File renamed without changes.
Loading