diff --git a/examples/simple/Cargo.toml b/examples/simple/Cargo.toml index 1adc0243d..9c77bffdd 100644 --- a/examples/simple/Cargo.toml +++ b/examples/simple/Cargo.toml @@ -9,5 +9,5 @@ name = "rust_ext" crate-type = ["cdylib"] [dependencies] -pyo3 = { version = "0.16", features = ["extension-module"] } +pyo3 = { version = "0.16", features = ["extension-module", "abi3-py37"] } numpy = { path = "../.." } diff --git a/src/npyffi/array.rs b/src/npyffi/array.rs index cda4ffd30..1470f8aac 100644 --- a/src/npyffi/array.rs +++ b/src/npyffi/array.rs @@ -1,9 +1,14 @@ //! Low-Level binding for [Array API](https://numpy.org/doc/stable/reference/c-api/array.html) -use libc::FILE; +//! +//! Note that NumPy's low-level allocation functions `PyArray_{malloc,realloc,free}` are not part of this module. +//! The reason is that they would be re-exports of the `PyMem_Raw{Malloc,Realloc,Free}` functions from PyO3, +//! but those are not unconditionally exported, i.e. they are not available when using the limited Python C-API. + use std::cell::Cell; use std::os::raw::*; use std::ptr::null; +use libc::FILE; use pyo3::ffi::{self, PyObject, PyTypeObject}; use crate::npyffi::*; @@ -394,12 +399,6 @@ pub unsafe fn PyArray_CheckExact(py: Python, op: *mut PyObject) -> c_int { (ffi::Py_TYPE(op) == PY_ARRAY_API.get_type_object(py, NpyTypes::PyArray_Type)) as _ } -// these are under `#if NPY_USE_PYMEM == 1` which seems to be always defined as 1 -pub use pyo3::ffi::{ - PyMem_RawFree as PyArray_free, PyMem_RawMalloc as PyArray_malloc, - PyMem_RawRealloc as PyArray_realloc, -}; - #[cfg(test)] mod tests { use super::PY_ARRAY_API;