diff --git a/Cargo.toml b/Cargo.toml index f330453c..75c7bff5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ savant_core = { path = "savant_core" } savant_core_py = { path = "savant_core_py" } [workspace.package] -version = "0.2.24" +version = "0.2.25" edition = "2021" authors = ["Ivan Kudriavtsev "] description = "Savant Rust core functions library" diff --git a/savant_algebra/Cargo.toml b/savant_algebra/Cargo.toml index d5652909..31cd7148 100644 --- a/savant_algebra/Cargo.toml +++ b/savant_algebra/Cargo.toml @@ -19,7 +19,7 @@ savant_rs = { path = "../savant_python" } parking_lot = "0.12" anyhow = "1" opentelemetry = "0.19" -numpy = {version = "0.19", features = ["nalgebra"]} +numpy = { version = "0.19", features = ["nalgebra"] } nalgebra = "0.32" ndarray = "0.15" num-traits = "0.2" @@ -29,11 +29,11 @@ log = "0.4" crate-type = ["cdylib", "lib"] [dependencies.pyo3] -version = "0.19" +version = "0.12" [features] extension-module = ["pyo3/extension-module"] default = ["extension-module"] [build-dependencies] -pyo3-build-config = "0.19" +pyo3-build-config = "0.21" diff --git a/savant_core_py/Cargo.toml b/savant_core_py/Cargo.toml index 3af19892..558ff10e 100644 --- a/savant_core_py/Cargo.toml +++ b/savant_core_py/Cargo.toml @@ -4,7 +4,7 @@ version.workspace = true edition.workspace = true authors.workspace = true description.workspace = true -homepage.workspace = true +homepage.workspace = true repository.workspace = true readme.workspace = true keywords.workspace = true @@ -16,14 +16,14 @@ rust-version.workspace = true crate-type = ["dylib"] [dependencies] -savant_core = {workspace = true} +savant_core = { workspace = true } serde_json = "1.0" serde = { version = "1.0", features = ["derive"] } anyhow = "1.0" thiserror = "1.0" geo = "0.26" lazy_static = "1.4" -parking_lot = {version = "0.12", features = ["deadlock_detection"]} +parking_lot = { version = "0.12", features = ["deadlock_detection"] } evalexpr = { version = "11", features = ["rand", "regex_support"] } log = "0.4" opentelemetry = "0.21" @@ -31,14 +31,14 @@ colored = "2" hashbrown = "0.14" [dependencies.pyo3] -version = "0.20" +version = "0.21" [dev-dependencies] serial_test = "2.0" [build-dependencies] -pyo3-build-config = "0.20" +pyo3-build-config = "0.21" cbindgen = "0.24" [package.metadata.maturin] diff --git a/savant_core_py/src/logging.rs b/savant_core_py/src/logging.rs index e5c72013..b46ef2e2 100644 --- a/savant_core_py/src/logging.rs +++ b/savant_core_py/src/logging.rs @@ -139,7 +139,7 @@ pub fn log_message_gil( level: LogLevel, target: &str, message: &str, - params: Option<&PyDict>, + params: Option<&Bound<'_, PyDict>>, no_gil: bool, ) { let params: Option<_> = params.map(|params| { diff --git a/savant_core_py/src/match_query.rs b/savant_core_py/src/match_query.rs index 418a8c70..7e8482fe 100644 --- a/savant_core_py/src/match_query.rs +++ b/savant_core_py/src/match_query.rs @@ -247,7 +247,7 @@ impl FloatExpression { /// #[staticmethod] #[pyo3(signature = (*list))] - fn one_of(list: &PyTuple) -> FloatExpression { + fn one_of(list: &Bound<'_, PyTuple>) -> FloatExpression { let mut vals = Vec::with_capacity(list.len()); for arg in list { let v = arg @@ -494,7 +494,7 @@ impl IntExpression { /// #[staticmethod] #[pyo3(signature = (*list))] - fn one_of(list: &PyTuple) -> IntExpression { + fn one_of(list: &Bound<'_, PyTuple>) -> IntExpression { let mut vals = Vec::with_capacity(list.len()); for arg in list { let v = arg @@ -711,7 +711,7 @@ impl StringExpression { /// #[staticmethod] #[pyo3(signature = (*list))] - fn one_of(list: &PyTuple) -> StringExpression { + fn one_of(list: &Bound<'_, PyTuple>) -> StringExpression { let mut vals = Vec::with_capacity(list.len()); for arg in list { let v = arg @@ -772,7 +772,7 @@ impl MatchQuery { /// #[staticmethod] #[pyo3(signature = (*list))] - fn and_(list: &PyTuple) -> MatchQuery { + fn and_(list: &Bound<'_, PyTuple>) -> MatchQuery { let mut v = Vec::with_capacity(list.len()); for arg in list { let q = arg @@ -813,7 +813,7 @@ impl MatchQuery { /// #[staticmethod] #[pyo3(signature = (*list))] - fn or_(list: &PyTuple) -> MatchQuery { + fn or_(list: &Bound<'_, PyTuple>) -> MatchQuery { let mut v = Vec::with_capacity(list.len()); for arg in list { let q = arg diff --git a/savant_core_py/src/primitives/attribute_value.rs b/savant_core_py/src/primitives/attribute_value.rs index fd47faa9..383d5342 100644 --- a/savant_core_py/src/primitives/attribute_value.rs +++ b/savant_core_py/src/primitives/attribute_value.rs @@ -2,8 +2,8 @@ use crate::primitives::segment::Intersection; use crate::primitives::{Point, PolygonalArea, RBBox}; use crate::with_gil; use pyo3::exceptions::{PyIndexError, PyValueError}; -use pyo3::types::PyBytes; -use pyo3::{pyclass, pymethods, Py, PyAny, PyObject, PyResult}; +use pyo3::types::{PyBytes, PyBytesMethods}; +use pyo3::{pyclass, pymethods, Bound, Py, PyAny, PyObject, PyResult}; use savant_core::primitives::any_object::AnyObject; use savant_core::primitives::attribute_value::AttributeValueVariant; use savant_core::primitives::rust; @@ -169,7 +169,7 @@ impl AttributeValue { /// #[staticmethod] #[pyo3(signature = (dims, blob, confidence = None))] - pub fn bytes(dims: Vec, blob: &PyBytes, confidence: Option) -> Self { + pub fn bytes(dims: Vec, blob: &Bound<'_, PyBytes>, confidence: Option) -> Self { Self(rust::AttributeValue { confidence, value: AttributeValueVariant::Bytes(dims, blob.as_bytes().to_vec()), @@ -520,7 +520,7 @@ impl AttributeValue { match &self.0.value { AttributeValueVariant::Bytes(dims, bytes) => Some(( dims.clone(), - with_gil!(|py| PyObject::from(PyBytes::new(py, bytes))), + with_gil!(|py| PyObject::from(PyBytes::new_bound(py, bytes))), )), _ => None, } diff --git a/savant_core_py/src/primitives/batch.rs b/savant_core_py/src/primitives/batch.rs index 51e2be2d..1cec7cda 100644 --- a/savant_core_py/src/primitives/batch.rs +++ b/savant_core_py/src/primitives/batch.rs @@ -4,8 +4,8 @@ use crate::primitives::object::BorrowedVideoObject; use crate::primitives::objects_view::VideoObjectsView; use crate::{release_gil, with_gil}; use pyo3::exceptions::PyRuntimeError; -use pyo3::types::PyBytes; -use pyo3::{pyclass, pymethods, PyObject, PyResult}; +use pyo3::types::{PyBytes, PyBytesMethods}; +use pyo3::{pyclass, pymethods, Bound, PyObject, PyResult}; use savant_core::primitives::rust; use savant_core::protobuf::{from_pb, ToProtobuf}; use std::collections::HashMap; @@ -80,7 +80,7 @@ impl VideoFrameBatch { }) })?; with_gil!(|py| { - let bytes = PyBytes::new(py, &bytes); + let bytes = PyBytes::new_bound(py, &bytes); Ok(PyObject::from(bytes)) }) } @@ -88,7 +88,7 @@ impl VideoFrameBatch { #[staticmethod] #[pyo3(name = "from_protobuf")] #[pyo3(signature = (bytes, no_gil = true))] - fn from_protobuf_gil(bytes: &PyBytes, no_gil: bool) -> PyResult { + fn from_protobuf_gil(bytes: &Bound<'_, PyBytes>, no_gil: bool) -> PyResult { let bytes = bytes.as_bytes(); release_gil!(no_gil, || { let obj = diff --git a/savant_core_py/src/primitives/frame.rs b/savant_core_py/src/primitives/frame.rs index 9ca361c7..bba0e7b5 100644 --- a/savant_core_py/src/primitives/frame.rs +++ b/savant_core_py/src/primitives/frame.rs @@ -10,8 +10,8 @@ use crate::primitives::objects_view::VideoObjectsView; use crate::release_gil; use crate::with_gil; use pyo3::exceptions::{PyRuntimeError, PyValueError}; -use pyo3::types::PyBytes; -use pyo3::{pyclass, pymethods, Py, PyAny, PyObject, PyResult}; +use pyo3::types::{PyBytes, PyBytesMethods}; +use pyo3::{pyclass, pymethods, Bound, Py, PyAny, PyObject, PyResult}; use savant_core::json_api::ToSerdeJsonValue; use savant_core::primitives::object::ObjectOperations; use savant_core::primitives::{rust, WithAttributes}; @@ -96,7 +96,7 @@ impl VideoFrameContent { } #[staticmethod] - pub fn internal(data: &PyBytes) -> Self { + pub fn internal(data: &Bound<'_, PyBytes>) -> Self { let bytes = data.as_bytes(); Self(rust::VideoFrameContent::Internal(bytes.to_vec())) } @@ -135,7 +135,7 @@ impl VideoFrameContent { match &self.0 { rust::VideoFrameContent::Internal(data) => { with_gil!(|py| { - let bytes = PyBytes::new_with(py, data.len(), |b: &mut [u8]| { + let bytes = PyBytes::new_bound_with(py, data.len(), |b: &mut [u8]| { b.copy_from_slice(data); Ok(()) })?; @@ -1107,7 +1107,7 @@ impl VideoFrame { }) })?; with_gil!(|py| { - let bytes = PyBytes::new(py, &bytes); + let bytes = PyBytes::new_bound(py, &bytes); Ok(PyObject::from(bytes)) }) } @@ -1115,7 +1115,7 @@ impl VideoFrame { #[staticmethod] #[pyo3(name = "from_protobuf")] #[pyo3(signature = (bytes, no_gil = true))] - fn from_protobuf_gil(bytes: &PyBytes, no_gil: bool) -> PyResult { + fn from_protobuf_gil(bytes: &Bound<'_, PyBytes>, no_gil: bool) -> PyResult { let bytes = bytes.as_bytes(); release_gil!(no_gil, || { let obj = from_pb::(bytes) diff --git a/savant_core_py/src/primitives/frame_update.rs b/savant_core_py/src/primitives/frame_update.rs index 9f2b8879..307ee17d 100644 --- a/savant_core_py/src/primitives/frame_update.rs +++ b/savant_core_py/src/primitives/frame_update.rs @@ -269,7 +269,7 @@ impl VideoFrameUpdate { }) })?; with_gil!(|py| { - let bytes = PyBytes::new(py, &bytes); + let bytes = PyBytes::new_bound(py, &bytes); Ok(PyObject::from(bytes)) }) } @@ -277,7 +277,7 @@ impl VideoFrameUpdate { #[staticmethod] #[pyo3(name = "from_protobuf")] #[pyo3(signature = (bytes, no_gil = true))] - fn from_protobuf_gil(bytes: &PyBytes, no_gil: bool) -> PyResult { + fn from_protobuf_gil(bytes: &Bound<'_, PyBytes>, no_gil: bool) -> PyResult { let bytes = bytes.as_bytes(); release_gil!(no_gil, || { let obj = diff --git a/savant_core_py/src/primitives/message/loader.rs b/savant_core_py/src/primitives/message/loader.rs index c49d656a..198ba745 100644 --- a/savant_core_py/src/primitives/message/loader.rs +++ b/savant_core_py/src/primitives/message/loader.rs @@ -1,8 +1,8 @@ use crate::primitives::message::Message; use crate::release_gil; use crate::utils::byte_buffer::ByteBuffer; -use pyo3::pyfunction; -use pyo3::types::PyBytes; +use pyo3::types::{PyBytes, PyBytesMethods}; +use pyo3::{pyfunction, Bound}; /// Loads a message from a byte array. The function is optionally GIL-free. /// @@ -66,7 +66,7 @@ pub fn load_message_from_bytebuffer_gil(buffer: &ByteBuffer, no_gil: bool) -> Me #[pyfunction] #[pyo3(name = "load_message_from_bytes")] #[pyo3(signature = (buffer, no_gil = true))] -pub fn load_message_from_bytes_gil(buffer: &PyBytes, no_gil: bool) -> Message { +pub fn load_message_from_bytes_gil(buffer: &Bound<'_, PyBytes>, no_gil: bool) -> Message { let bytes = buffer.as_bytes(); release_gil!(no_gil, || Message(savant_core::message::load_message( bytes diff --git a/savant_core_py/src/primitives/message/saver.rs b/savant_core_py/src/primitives/message/saver.rs index bafeabd1..ad027abe 100644 --- a/savant_core_py/src/primitives/message/saver.rs +++ b/savant_core_py/src/primitives/message/saver.rs @@ -84,7 +84,7 @@ pub fn save_message_to_bytes_gil(message: &Message, no_gil: bool) -> PyResult PyResult { + fn from_protobuf_gil(bytes: &Bound<'_, PyBytes>, no_gil: bool) -> PyResult { let bytes = bytes.as_bytes(); release_gil!(no_gil, || { let obj = from_pb::(bytes) @@ -541,7 +541,7 @@ impl BorrowedVideoObject { )) })?; with_gil!(|py| { - let bytes = PyBytes::new(py, &bytes); + let bytes = PyBytes::new_bound(py, &bytes); Ok(PyObject::from(bytes)) }) } diff --git a/savant_core_py/src/primitives/user_data.rs b/savant_core_py/src/primitives/user_data.rs index 50a8d83f..09e5d33e 100644 --- a/savant_core_py/src/primitives/user_data.rs +++ b/savant_core_py/src/primitives/user_data.rs @@ -3,8 +3,8 @@ use crate::primitives::attribute_value::AttributeValue; use crate::primitives::message::Message; use crate::{release_gil, with_gil}; use pyo3::exceptions::PyRuntimeError; -use pyo3::types::PyBytes; -use pyo3::{pyclass, pymethods, Py, PyAny, PyObject, PyResult}; +use pyo3::types::{PyBytes, PyBytesMethods}; +use pyo3::{pyclass, pymethods, Bound, Py, PyAny, PyObject, PyResult}; use savant_core::json_api::ToSerdeJsonValue; use savant_core::primitives::rust as rust_primitives; use savant_core::primitives::{rust, WithAttributes}; @@ -203,7 +203,7 @@ impl UserData { }) })?; with_gil!(|py| { - let bytes = PyBytes::new(py, &bytes); + let bytes = PyBytes::new_bound(py, &bytes); Ok(PyObject::from(bytes)) }) } @@ -211,7 +211,7 @@ impl UserData { #[staticmethod] #[pyo3(name = "from_protobuf")] #[pyo3(signature = (bytes, no_gil = true))] - fn from_protobuf_gil(bytes: &PyBytes, no_gil: bool) -> PyResult { + fn from_protobuf_gil(bytes: &Bound<'_, PyBytes>, no_gil: bool) -> PyResult { let bytes = bytes.as_bytes(); release_gil!(no_gil, || { let obj = diff --git a/savant_core_py/src/utils/byte_buffer.rs b/savant_core_py/src/utils/byte_buffer.rs index dd11ec28..6f695b59 100644 --- a/savant_core_py/src/utils/byte_buffer.rs +++ b/savant_core_py/src/utils/byte_buffer.rs @@ -27,7 +27,7 @@ pub struct ByteBuffer { #[pymethods] impl ByteBuffer { #[new] - fn create(v: &PyBytes, checksum: Option) -> PyResult { + fn create(v: &Bound<'_, PyBytes>, checksum: Option) -> PyResult { Ok(Self::new(v.as_bytes().to_vec(), checksum)) } @@ -80,7 +80,7 @@ impl ByteBuffer { #[pyo3(name = "bytes")] pub fn bytes_py(&self) -> PyObject { with_gil!(|py| { - let bytes = PyBytes::new(py, self.inner.as_slice()); + let bytes = PyBytes::new_bound(py, self.inner.as_slice()); PyObject::from(bytes) }) } diff --git a/savant_core_py/src/utils/otlp.rs b/savant_core_py/src/utils/otlp.rs index 5544ce63..6895df8d 100644 --- a/savant_core_py/src/utils/otlp.rs +++ b/savant_core_py/src/utils/otlp.rs @@ -174,9 +174,9 @@ impl TelemetrySpan { fn __exit__( &self, - exc_type: Option<&PyAny>, - exc_value: Option<&PyAny>, - traceback: Option<&PyAny>, + exc_type: Option<&Bound<'_, PyAny>>, + exc_value: Option<&Bound<'_, PyAny>>, + traceback: Option<&Bound<'_, PyAny>>, ) -> PyResult<()> { with_gil!(|py| { if let Some(e) = exc_type { @@ -189,13 +189,13 @@ impl TelemetrySpan { attrs.insert("python.exception.type".to_string(), format!("{:?}", e)); if let Some(v) = exc_value { - if let Ok(e) = PyAny::downcast::(v) { + if let Ok(e) = PyAny::downcast::(v.as_gil_ref()) { attrs.insert("python.exception.value".to_string(), e.to_string()); } } if let Some(t) = traceback { - let traceback = PyAny::downcast::(t).unwrap(); + let traceback = PyAny::downcast::(t.as_gil_ref()).unwrap(); if let Ok(formatted) = traceback.format() { attrs.insert("python.exception.traceback".to_string(), formatted); } @@ -416,9 +416,9 @@ impl MaybeTelemetrySpan { fn __exit__( &self, - exc_type: Option<&PyAny>, - exc_value: Option<&PyAny>, - traceback: Option<&PyAny>, + exc_type: Option<&Bound<'_, PyAny>>, + exc_value: Option<&Bound<'_, PyAny>>, + traceback: Option<&Bound<'_, PyAny>>, ) -> PyResult<()> { if let Some(span) = &self.span { span.__exit__(exc_type, exc_value, traceback)?; diff --git a/savant_core_py/src/zmq/blocking.rs b/savant_core_py/src/zmq/blocking.rs index 69d77844..28ff84f4 100644 --- a/savant_core_py/src/zmq/blocking.rs +++ b/savant_core_py/src/zmq/blocking.rs @@ -3,8 +3,8 @@ use crate::release_gil; use crate::zmq::configs::{ReaderConfig, WriterConfig}; use crate::zmq::results; use pyo3::exceptions::PyRuntimeError; -use pyo3::types::PyBytes; -use pyo3::{pyclass, pymethods, PyObject, PyResult}; +use pyo3::types::{PyBytes, PyBytesMethods}; +use pyo3::{pyclass, pymethods, Bound, PyObject, PyResult}; use savant_core::transport::zeromq; /// Blocking Writer with GIL release on long-lasting `send_*` operations. @@ -123,7 +123,7 @@ impl BlockingWriter { &mut self, topic: &str, message: &Message, - extra: &PyBytes, + extra: &Bound<'_, PyBytes>, ) -> PyResult { if self.0.is_none() { return Err(PyRuntimeError::new_err("Writer is not started.")); @@ -228,7 +228,7 @@ impl BlockingReader { /// source_id : bytes /// Source ID to blacklist. /// - pub fn blacklist_source(&self, source_id: &PyBytes) { + pub fn blacklist_source(&self, source_id: &Bound<'_, PyBytes>) { if self.0.is_none() { return; } @@ -249,7 +249,7 @@ impl BlockingReader { /// bool /// `true` if the source is blacklisted. /// - pub fn is_blacklisted(&self, source_id: &PyBytes) -> bool { + pub fn is_blacklisted(&self, source_id: &Bound<'_, PyBytes>) -> bool { if self.0.is_none() { return false; } diff --git a/savant_core_py/src/zmq/nonblocking.rs b/savant_core_py/src/zmq/nonblocking.rs index dafa5a5c..82ee7902 100644 --- a/savant_core_py/src/zmq/nonblocking.rs +++ b/savant_core_py/src/zmq/nonblocking.rs @@ -3,8 +3,8 @@ use crate::release_gil; use crate::zmq::configs::{ReaderConfig, WriterConfig}; use crate::zmq::results; use pyo3::exceptions::PyRuntimeError; -use pyo3::types::PyBytes; -use pyo3::{pyclass, pymethods, PyObject, PyResult}; +use pyo3::types::{PyBytes, PyBytesMethods}; +use pyo3::{pyclass, pymethods, Bound, PyObject, PyResult}; use savant_core::transport::zeromq; /// A non-blocking reader. Does not release GIL when uses `receive` convenience method, which is blocking. @@ -113,7 +113,7 @@ impl NonBlockingReader { /// source_id : bytes /// Source ID to blacklist. /// - pub fn blacklist_source(&self, source_id: &PyBytes) { + pub fn blacklist_source(&self, source_id: &Bound<'_, PyBytes>) { let bytes = source_id.as_bytes(); self.0.blacklist_source(bytes); } @@ -130,7 +130,7 @@ impl NonBlockingReader { /// bool /// `true` if the source is blacklisted. /// - pub fn is_blacklisted(&self, source_id: &PyBytes) -> bool { + pub fn is_blacklisted(&self, source_id: &Bound<'_, PyBytes>) -> bool { let bytes = source_id.as_bytes(); self.0.is_blacklisted(bytes) } @@ -280,7 +280,7 @@ impl NonBlockingWriter { &mut self, topic: &str, message: &Message, - extra: &PyBytes, + extra: &Bound<'_, PyBytes>, ) -> PyResult { let bytes = extra.as_bytes(); Ok(WriteOperationResult( diff --git a/savant_core_py/src/zmq/results.rs b/savant_core_py/src/zmq/results.rs index 8797fd9a..7a8ec068 100644 --- a/savant_core_py/src/zmq/results.rs +++ b/savant_core_py/src/zmq/results.rs @@ -179,10 +179,11 @@ impl ReaderResultMessage { fn data(&self, index: usize) -> PyResult> { if index < self.data.len() { with_gil!(|py| { - let pybytes = PyBytes::new_with(py, self.data[index].len(), |b: &mut [u8]| { - b.copy_from_slice(&self.data[index]); - Ok(()) - })?; + let pybytes = + PyBytes::new_bound_with(py, self.data[index].len(), |b: &mut [u8]| { + b.copy_from_slice(&self.data[index]); + Ok(()) + })?; Ok(Some(pybytes.into())) }) } else { diff --git a/savant_plugins/savant_plugin_sample/Cargo.toml b/savant_plugins/savant_plugin_sample/Cargo.toml index 6dcb68e6..5e7f4b17 100644 --- a/savant_plugins/savant_plugin_sample/Cargo.toml +++ b/savant_plugins/savant_plugin_sample/Cargo.toml @@ -23,10 +23,10 @@ savant_core = { workspace = true } anyhow = "1" [dependencies.pyo3] -version = "0.20" +version = "0.21" [build-dependencies] -pyo3-build-config = "0.20" +pyo3-build-config = "0.21" [package.metadata.maturin] python-source = "python" diff --git a/savant_plugins/savant_plugin_sample/src/lib.rs b/savant_plugins/savant_plugin_sample/src/lib.rs index a1b90a05..044b9dd6 100644 --- a/savant_plugins/savant_plugin_sample/src/lib.rs +++ b/savant_plugins/savant_plugin_sample/src/lib.rs @@ -74,7 +74,7 @@ pub fn access_object(o: &BorrowedVideoObject) { } #[pymodule] -fn savant_plugin_sample(_: Python, m: &PyModule) -> PyResult<()> { +fn savant_plugin_sample(_: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_function(wrap_pyfunction!(access_frame, m)?)?; m.add_function(wrap_pyfunction!(access_object, m)?)?; m.add_function(wrap_pyfunction!(get_instance, m)?)?; diff --git a/savant_python/Cargo.toml b/savant_python/Cargo.toml index 7249a081..4c72eda4 100644 --- a/savant_python/Cargo.toml +++ b/savant_python/Cargo.toml @@ -4,7 +4,7 @@ version.workspace = true edition.workspace = true authors.workspace = true description.workspace = true -homepage.workspace = true +homepage.workspace = true repository.workspace = true readme.workspace = true keywords.workspace = true @@ -21,10 +21,10 @@ pretty_env_logger = "0.5" [dependencies.pyo3] -version = "0.20" +version = "0.21" [build-dependencies] -pyo3-build-config = "0.20" +pyo3-build-config = "0.21" [package.metadata.maturin] python-source = "python" diff --git a/savant_python/src/lib.rs b/savant_python/src/lib.rs index 7b82fb3d..2aea17fd 100644 --- a/savant_python/src/lib.rs +++ b/savant_python/src/lib.rs @@ -56,7 +56,7 @@ use savant_core_py::zmq::{blocking, nonblocking}; use savant_core_py::*; #[pymodule] -pub fn zmq(_py: Python, m: &PyModule) -> PyResult<()> { +pub fn zmq(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_class::()?; // PYI m.add_class::()?; // PYI m.add_class::()?; // PYI @@ -85,7 +85,7 @@ pub fn zmq(_py: Python, m: &PyModule) -> PyResult<()> { } #[pymodule] -pub fn symbol_mapper_module(_py: Python, m: &PyModule) -> PyResult<()> { +pub fn symbol_mapper_module(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_function(wrap_pyfunction!(build_model_object_key_py, m)?)?; m.add_function(wrap_pyfunction!(clear_symbol_maps_py, m)?)?; m.add_function(wrap_pyfunction!(dump_registry_gil, m)?)?; @@ -107,7 +107,7 @@ pub fn symbol_mapper_module(_py: Python, m: &PyModule) -> PyResult<()> { } #[pymodule] -pub fn serialization_module(_py: Python, m: &PyModule) -> PyResult<()> { +pub fn serialization_module(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { // ser deser m.add_function(wrap_pyfunction!(save_message_gil, m)?)?; m.add_function(wrap_pyfunction!(save_message_to_bytebuffer_gil, m)?)?; @@ -123,7 +123,7 @@ pub fn serialization_module(_py: Python, m: &PyModule) -> PyResult<()> { } #[pymodule] -pub fn utils(_py: Python, m: &PyModule) -> PyResult<()> { +pub fn utils(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_function(wrap_pyfunction!(eval_expr, m)?)?; // PYI m.add_function(wrap_pyfunction!(gen_frame, m)?)?; // PYI m.add_function(wrap_pyfunction!(gen_empty_frame, m)?)?; // PYI @@ -144,7 +144,7 @@ pub fn utils(_py: Python, m: &PyModule) -> PyResult<()> { } #[pymodule] -pub fn geometry(_py: Python, m: &PyModule) -> PyResult<()> { +pub fn geometry(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_class::()?; m.add_class::()?; m.add_class::()?; @@ -156,7 +156,7 @@ pub fn geometry(_py: Python, m: &PyModule) -> PyResult<()> { } #[pymodule] -pub fn primitives(_py: Python, m: &PyModule) -> PyResult<()> { +pub fn primitives(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_class::()?; // PYI m.add_class::()?; // PYI m.add_class::()?; // PYI @@ -184,7 +184,7 @@ pub fn primitives(_py: Python, m: &PyModule) -> PyResult<()> { } #[pymodule] -pub(crate) fn pipeline(_py: Python, m: &PyModule) -> PyResult<()> { +pub(crate) fn pipeline(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_class::()?; m.add_class::()?; m.add_class::()?; @@ -197,7 +197,7 @@ pub(crate) fn pipeline(_py: Python, m: &PyModule) -> PyResult<()> { } #[pymodule] -pub fn match_query(_py: Python, m: &PyModule) -> PyResult<()> { +pub fn match_query(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_class::()?; m.add_class::()?; m.add_class::()?; @@ -220,7 +220,7 @@ pub fn match_query(_py: Python, m: &PyModule) -> PyResult<()> { } #[pymodule] -pub(crate) fn logging(_py: Python, m: &PyModule) -> PyResult<()> { +pub(crate) fn logging(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_class::()?; m.add_function(wrap_pyfunction!(set_log_level, m)?)?; m.add_function(wrap_pyfunction!(get_log_level, m)?)?; @@ -230,7 +230,7 @@ pub(crate) fn logging(_py: Python, m: &PyModule) -> PyResult<()> { } #[pymodule] -pub fn draw_spec(_py: Python, m: &PyModule) -> PyResult<()> { +pub fn draw_spec(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { m.add_class::()?; // PYI m.add_class::()?; // PYI m.add_class::()?; // PYI @@ -244,7 +244,7 @@ pub fn draw_spec(_py: Python, m: &PyModule) -> PyResult<()> { } #[pymodule] -fn savant_rs(py: Python, m: &PyModule) -> PyResult<()> { +fn savant_rs(py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> { let log_env_var_name = "LOGLEVEL"; let log_env_var_level = "trace"; if std::env::var(log_env_var_name).is_err() { @@ -269,8 +269,8 @@ fn savant_rs(py: Python, m: &PyModule) -> PyResult<()> { m.add_wrapped(wrap_pymodule!(self::logging))?; // PYI m.add_wrapped(wrap_pymodule!(self::zmq))?; // PYI - let sys = PyModule::import(py, "sys")?; - let sys_modules: &PyDict = sys.getattr("modules")?.downcast()?; + let sys = PyModule::import_bound(py, "sys")?; + let sys_modules: &PyDict = sys.as_gil_ref().getattr("modules")?.downcast()?; sys_modules.set_item("savant_rs.primitives", m.getattr("primitives")?)?; sys_modules.set_item("savant_rs.pipeline", m.getattr("pipeline")?)?;