Browse Source

Add pyo3 special method

tags/v0.3.12-fix
haixuantao 6 months ago
parent
commit
d03b6d138b
6 changed files with 62 additions and 19 deletions
  1. +47
    -0
      Cargo.lock
  2. +1
    -1
      apis/python/node/Cargo.toml
  3. +2
    -2
      apis/python/node/src/lib.rs
  4. +1
    -1
      libraries/extensions/ros2-bridge/python/Cargo.toml
  5. +7
    -8
      libraries/extensions/ros2-bridge/python/src/lib.rs
  6. +4
    -7
      libraries/extensions/ros2-bridge/python/src/qos.rs

+ 47
- 0
Cargo.lock View File

@@ -3230,6 +3230,7 @@ dependencies = [
"futures",
"pyo3",
"pyo3-build-config",
"pyo3_special_method_derive",
"pythonize",
"serde_yaml 0.9.34+deprecated",
"tokio",
@@ -3414,6 +3415,7 @@ dependencies = [
"eyre",
"futures",
"pyo3",
"pyo3_special_method_derive",
"serde",
"serde_assert",
]
@@ -8992,6 +8994,29 @@ dependencies = [
"syn 2.0.101",
]

[[package]]
name = "pyo3_special_method_derive"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b75ccfc0eef7c0478db8aa23d23e97b39c74e29da21d9bf1e1934e63ad0709d"
dependencies = [
"pyo3",
"pyo3_special_method_derive_macro",
]

[[package]]
name = "pyo3_special_method_derive_macro"
version = "0.4.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cfc6e17b94c919f8295729dcddd368b7cd78231c39a3c23cdeec77b5834010cf"
dependencies = [
"proc-macro2",
"pyo3",
"quote",
"quote_into",
"syn 2.0.101",
]

[[package]]
name = "python3-dll-a"
version = "0.2.13"
@@ -9178,6 +9203,28 @@ dependencies = [
"proc-macro2",
]

[[package]]
name = "quote_into"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "93886ed56f228a5d960fc4d26afa3736df12a251872869cf24f5efe5f07699b9"
dependencies = [
"proc-macro2",
"quote",
"quote_into_macro",
]

[[package]]
name = "quote_into_macro"
version = "0.2.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "36b828998c40452b5afe441c75194e93181432e669585f4ceb7b0d32a3f73525"
dependencies = [
"proc-macro2",
"quote",
"syn 1.0.109",
]

[[package]]
name = "r-efi"
version = "5.2.0"


+ 1
- 1
apis/python/node/Cargo.toml View File

@@ -30,7 +30,7 @@ arrow = { workspace = true, features = ["pyarrow"] }
pythonize = { workspace = true }
futures = "0.3.28"
dora-ros2-bridge-python = { workspace = true }
# pyo3_special_method_derive = "0.4.2"
pyo3_special_method_derive = "0.4.3"
tokio = { version = "1.24.2", features = ["rt"] }

[build-dependencies]


+ 2
- 2
apis/python/node/src/lib.rs View File

@@ -17,7 +17,7 @@ use eyre::Context;
use futures::{Stream, StreamExt};
use pyo3::prelude::*;
use pyo3::types::{PyBytes, PyDict};
/// use pyo3_special_method_derive::{Dict, Dir, Repr, Str};
use pyo3_special_method_derive::{Dict, Dir, Repr, Str};

/// The custom node API lets you integrate `dora` into your application.
/// It allows you to retrieve input and send output in any fashion you want.
@@ -32,7 +32,7 @@ use pyo3::types::{PyBytes, PyDict};
///
/// :type node_id: str, optional
#[pyclass]
/// #[derive(Dir, Dict, Str, Repr)]
#[derive(Dir, Dict, Str, Repr)]
pub struct Node {
events: Events,
node: DelayedCleanup<DoraNode>,


+ 1
- 1
libraries/extensions/ros2-bridge/python/Cargo.toml View File

@@ -12,7 +12,7 @@ eyre = "0.6"
serde = "1.0.166"
arrow = { workspace = true, features = ["pyarrow"] }
futures = "0.3.28"
# pyo3_special_method_derive = "0.4.2"
pyo3_special_method_derive = "0.4.3"

[dev-dependencies]
serde_assert = "0.7.1"

+ 7
- 8
libraries/extensions/ros2-bridge/python/src/lib.rs View File

@@ -18,7 +18,7 @@ use pyo3::{
types::{PyAnyMethods, PyDict, PyList, PyModule, PyModuleMethods},
Bound, PyAny, PyObject, PyResult, Python,
};
/// use pyo3_special_method_derive::{Dict, Dir, Repr, Str};
use pyo3_special_method_derive::{Dict, Dir, Repr, Str};
use typed::{deserialize::StructDeserializer, TypeInfo, TypedValue};

pub mod qos;
@@ -46,7 +46,7 @@ pub mod typed;
/// :type ros_paths: typing.List[str], optional
///
#[pyclass]
/// #[derive(Str, Repr, Dir, Dict)]
#[derive(Str, Repr, Dir, Dict)]
pub struct Ros2Context {
context: ros2_client::Context,
messages: Arc<HashMap<String, HashMap<String, Message>>>,
@@ -150,7 +150,7 @@ impl Ros2Context {
/// See: https://github.com/jhelovuo/ros2-client/issues/4
///
#[pyclass]
/// #[derive(Str, Repr, Dir, Dict)]
#[derive(Str, Repr, Dir, Dict)]
pub struct Ros2Node {
node: ros2_client::Node,
messages: Arc<HashMap<String, HashMap<String, Message>>>,
@@ -257,8 +257,7 @@ impl Ros2Node {
/// ROS2 Node Options
/// :type rosout: bool, optional
///
#[derive(Clone, Default)]
/// , Str, Repr, Dir, Dict)]
#[derive(Clone, Default, Str, Repr, Dir, Dict)]
#[pyclass]
#[non_exhaustive]
pub struct Ros2NodeOptions {
@@ -289,7 +288,7 @@ impl From<Ros2NodeOptions> for ros2_client::NodeOptions {
/// - dora Ros2 bridge functionality is considered **unstable**. It may be changed
/// at any point without it being considered a breaking change.
#[pyclass]
/// #[derive(Str, Repr, Dir, Dict)]
#[derive(Str, Repr, Dir, Dict)]
#[non_exhaustive]
pub struct Ros2Topic {
topic: rustdds::Topic,
@@ -302,7 +301,7 @@ pub struct Ros2Topic {
/// - dora Ros2 bridge functionality is considered **unstable**. It may be changed
/// at any point without it being considered a breaking change.
#[pyclass]
/// #[derive(Str, Repr, Dir, Dict)]
#[derive(Str, Repr, Dir, Dict)]
#[non_exhaustive]
pub struct Ros2Publisher {
publisher: ros2_client::Publisher<TypedValue<'static>>,
@@ -373,7 +372,7 @@ impl Ros2Publisher {
/// - dora Ros2 bridge functionality is considered **unstable**. It may be changed
/// at any point without it being considered a breaking change.
#[pyclass]
/// #[derive(Str, Repr, Dir, Dict)]
#[derive(Str, Repr, Dir, Dict)]
#[non_exhaustive]
pub struct Ros2Subscription {
deserializer: StructDeserializer<'static>,


+ 4
- 7
libraries/extensions/ros2-bridge/python/src/qos.rs View File

@@ -1,6 +1,6 @@
use ::dora_ros2_bridge::rustdds::{self, policy};
use pyo3::prelude::{pyclass, pymethods};
/// use pyo3_special_method_derive::{Dict, Dir, Repr, Str};
use pyo3_special_method_derive::{Dict, Dir, Repr, Str};

/// ROS2 QoS Policy
///
@@ -13,8 +13,7 @@ use pyo3::prelude::{pyclass, pymethods};
/// :type keep_last: int, optional
/// :rtype: dora.Ros2QoSPolicies
///
#[derive(Clone)]
/// , Str, Repr, Dir, Dict)]
#[derive(Clone, Str, Repr, Dir, Dict)]
#[pyclass]
#[non_exhaustive]
pub struct Ros2QosPolicies {
@@ -80,8 +79,7 @@ impl From<Ros2QosPolicies> for rustdds::QosPolicies {
/// DDS 2.2.3.4 DURABILITY
///
/// :rtype: dora.Ros2Durability
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
/// , Str, Repr, Dir, Dict)]
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Str, Repr, Dir, Dict)]
#[pyclass(eq, eq_int)]
pub enum Ros2Durability {
Volatile,
@@ -107,8 +105,7 @@ impl From<Ros2Durability> for policy::Durability {

/// DDS 2.2.3.11 LIVELINESS
/// :rtype: dora.Ros2Liveliness
#[derive(Copy, Clone, PartialEq)]
/// , Str, Repr, Dir, Dict)]
#[derive(Copy, Clone, PartialEq, Str, Repr, Dir, Dict)]
#[pyclass(eq, eq_int)]
pub enum Ros2Liveliness {
Automatic,


Loading…
Cancel
Save