diff --git a/Cargo.lock b/Cargo.lock index 3e01d29..03b1aa7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1641,6 +1641,7 @@ dependencies = [ [[package]] name = "pyo3-arrow" version = "0.18.0" +source = "git+https://github.com/kylebarron/arro3?rev=7cfe579bab03406bf5d3e4824e171bf7204b43cc#7cfe579bab03406bf5d3e4824e171bf7204b43cc" dependencies = [ "arrow-array", "arrow-buffer", diff --git a/Cargo.toml b/Cargo.toml index 661b3fc..c4d2e10 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,7 +36,8 @@ numpy = "0.28" object_store = "0.13" parquet = "59" pyo3 = { version = "0.28", features = ["macros", "indexmap"] } -pyo3-arrow = { path = "pyo3-arrow" } +# pyo3-arrow = { path = "pyo3-arrow" } +pyo3-arrow = { git = "https://github.com/kylebarron/arro3", rev = "7cfe579bab03406bf5d3e4824e171bf7204b43cc" } pyo3-async-runtimes = { version = "0.28", features = ["tokio-runtime"] } pyo3-file = { git = "https://github.com/kylebarron/pyo3-file", rev = "f724ceaa7e06e7d227bf40b1d60adbb842963a44" } pyo3-object_store = "0.9" diff --git a/pyo3-arrow/Cargo.lock b/pyo3-arrow/Cargo.lock index f49117f..ea07c5f 100644 --- a/pyo3-arrow/Cargo.lock +++ b/pyo3-arrow/Cargo.lock @@ -502,9 +502,9 @@ dependencies = [ [[package]] name = "numpy" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "778da78c64ddc928ebf5ad9df5edf0789410ff3bdbf3619aed51cd789a6af1e2" +checksum = "6a5b15d63a5ff39e378daed0e1340d3a5964703ea9712eb09a0dc66fade996f4" dependencies = [ "half", "libc", @@ -567,9 +567,9 @@ dependencies = [ [[package]] name = "pyo3" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcf3ccafdf54c050be48a3a086d372f77ba6615f5057211607cd30e5ac5cec6d" +checksum = "cd274650b21d4bfc26a0a47587962c1edb425f69287324355cd040c3ea66071c" dependencies = [ "chrono", "chrono-tz", @@ -603,18 +603,18 @@ dependencies = [ [[package]] name = "pyo3-build-config" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "972720a441c91fd9c49f212a1d2d74c6e3803b231ebc8d66c51efbd7ccab11c8" +checksum = "c5e2a7d2f0d013342f295c048ad19237add5154a55b1c5a254c0ec93d4109078" dependencies = [ "target-lexicon", ] [[package]] name = "pyo3-ffi" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5994456d9dab8934d600d3867571b6410f24fbd6002570ad56356733eb54859b" +checksum = "ca85c467da1bbc8d866eea5deff9cf29ea5f7785054a17da36e65bda9c05845b" dependencies = [ "libc", "pyo3-build-config", @@ -622,9 +622,9 @@ dependencies = [ [[package]] name = "pyo3-macros" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11ce9cc8d81b3c4969748807604d92b4eef363c5bb82b1a1bdb34ec6f1093a18" +checksum = "9ac53762fd065daa3194dd09337a38bd793a188100fd1a9304c4ab312d901771" dependencies = [ "proc-macro2", "pyo3-macros-backend", @@ -634,13 +634,12 @@ dependencies = [ [[package]] name = "pyo3-macros-backend" -version = "0.28.0" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eaf4b60036a154d23282679b658e3cc7d88d3b8c9a40b43824785f232d2e1b98" +checksum = "4ca3a1557399783172dc5bf39cfca835157732532cba56b71d2292161e53b362" dependencies = [ "heck", "proc-macro2", - "pyo3-build-config", "quote", "syn", ] diff --git a/pyo3-arrow/Cargo.toml b/pyo3-arrow/Cargo.toml index fa32d5f..ddfa9dd 100644 --- a/pyo3-arrow/Cargo.toml +++ b/pyo3-arrow/Cargo.toml @@ -27,10 +27,10 @@ arrow-schema = "59" arrow-select = "59" chrono = "0.4" chrono-tz = "0.10" -pyo3 = { version = "0.28", features = ["chrono", "chrono-tz", "indexmap"] } +pyo3 = { version = "0.29", features = ["chrono", "chrono-tz", "indexmap"] } half = "2" indexmap = "2" -numpy = { version = "0.28", features = ["half"] } +numpy = { version = "0.29", features = ["half"] } thiserror = "1" [lib] diff --git a/pyo3-arrow/src/ffi/to_python/utils.rs b/pyo3-arrow/src/ffi/to_python/utils.rs index 2a3b836..28c1704 100644 --- a/pyo3-arrow/src/ffi/to_python/utils.rs +++ b/pyo3-arrow/src/ffi/to_python/utils.rs @@ -1,4 +1,4 @@ -use std::ffi::CString; +use std::ffi::CStr; use std::sync::Arc; use arrow_array::ffi::{FFI_ArrowArray, FFI_ArrowSchema}; @@ -13,6 +13,10 @@ use crate::ffi::from_python::utils::import_schema_pycapsule; use crate::ffi::to_python::ffi_stream::new_stream; use crate::ffi::{ArrayIterator, ArrayReader}; +const ARRAY_CAPSULE_NAME: &CStr = c"arrow_array"; +const SCHEMA_CAPSULE_NAME: &CStr = c"arrow_schema"; +const STREAM_CAPSULE_NAME: &CStr = c"arrow_array_stream"; + /// Export a [`arrow_schema::Schema`], [`arrow_schema::Field`], or [`arrow_schema::DataType`] to a /// PyCapsule holding an Arrow C Schema pointer. pub fn to_schema_pycapsule( @@ -20,8 +24,7 @@ pub fn to_schema_pycapsule( field: impl TryInto, ) -> PyArrowResult> { let ffi_schema: FFI_ArrowSchema = field.try_into()?; - let schema_capsule_name = CString::new("arrow_schema").unwrap(); - let schema_capsule = PyCapsule::new(py, ffi_schema, Some(schema_capsule_name))?; + let schema_capsule = PyCapsule::new_with_value(py, ffi_schema, SCHEMA_CAPSULE_NAME)?; Ok(schema_capsule) } @@ -53,11 +56,8 @@ pub fn to_array_pycapsules<'py>( let ffi_schema = FFI_ArrowSchema::try_from(&field)?; let ffi_array = FFI_ArrowArray::new(&array_data); - let schema_capsule_name = CString::new("arrow_schema").unwrap(); - let array_capsule_name = CString::new("arrow_array").unwrap(); - - let schema_capsule = PyCapsule::new(py, ffi_schema, Some(schema_capsule_name))?; - let array_capsule = PyCapsule::new(py, ffi_array, Some(array_capsule_name))?; + let schema_capsule = PyCapsule::new_with_value(py, ffi_schema, SCHEMA_CAPSULE_NAME)?; + let array_capsule = PyCapsule::new_with_value(py, ffi_array, ARRAY_CAPSULE_NAME)?; let tuple = PyTuple::new(py, vec![schema_capsule, array_capsule])?; Ok(tuple) @@ -89,6 +89,9 @@ pub fn to_stream_pycapsule<'py>( } let ffi_stream = new_stream(array_reader); - let stream_capsule_name = CString::new("arrow_array_stream").unwrap(); - Ok(PyCapsule::new(py, ffi_stream, Some(stream_capsule_name))?) + Ok(PyCapsule::new_with_value( + py, + ffi_stream, + STREAM_CAPSULE_NAME, + )?) }