Skip to content

Update pyo3 requirement from 0.26 to 0.27#30

Merged
SunDoge merged 2 commits intoSunDoge:mainfrom
weiji14:pyo3-0.27
Nov 3, 2025
Merged

Update pyo3 requirement from 0.26 to 0.27#30
SunDoge merged 2 commits intoSunDoge:mainfrom
weiji14:pyo3-0.27

Conversation

@weiji14
Copy link
Copy Markdown
Collaborator

@weiji14 weiji14 commented Oct 24, 2025

Updates the requirements on pyo3 to permit the latest version.

Xref https://pyo3.rs/v0.27.0/migration.html#from-026-to-027. Change method from extract_bound to extract

Fixes these warnings:

Details
$ cargo test --all-features
   Compiling dlpark v0.6.0 (/home/user/projects/dlpark)
error[E0407]: method `extract_bound` is not a member of trait `FromPyObject`
  --> src/convertor/python.rs:69:5
   |
69 | /     fn extract_bound(ob: &pyo3::Bound<'py, pyo3::PyAny>) -> pyo3::PyResult<Self> {
70 | |         let ptr = capsule_to_raw_dlpack(ob.as_ptr(), DLTENSOR, USED_DLTENSOR);
71 | |         unsafe { Ok(SafeManagedTensor::from_raw(ptr as *mut _)) }
72 | |     }
   | |_____^ not a member of trait `FromPyObject`

error[E0407]: method `extract_bound` is not a member of trait `FromPyObject`
  --> src/convertor/python.rs:90:5
   |
90 | /     fn extract_bound(ob: &pyo3::Bound<'py, pyo3::PyAny>) -> pyo3::PyResult<Self> {
91 | |         let ptr = capsule_to_raw_dlpack(ob.as_ptr(), DLTENSOR_VERSIONED, USED_DLTENSOR_VERSIONED);
92 | |         unsafe { Ok(SafeManagedTensorVersioned::from_raw(ptr as *mut _)) }
93 | |     }
   | |_____^ not a member of trait `FromPyObject`

error[E0107]: trait takes 2 lifetime arguments but 1 lifetime argument was supplied
   --> src/convertor/python.rs:68:11
    |
 68 | impl<'py> FromPyObject<'py> for SafeManagedTensor {
    |           ^^^^^^^^^^^^ --- supplied 1 lifetime argument
    |           |
    |           expected 2 lifetime arguments
    |
note: trait defined here, with 2 lifetime parameters: `'a`, `'py`
   --> /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/pyo3-0.27.1/src/conversion.rs:376:11
    |
376 | pub trait FromPyObject<'a, 'py>: Sized {
    |           ^^^^^^^^^^^^ --  ---
help: add missing lifetime argument
    |
 68 | impl<'py> FromPyObject<'py, 'py> for SafeManagedTensor {
    |                           +++++

error[E0107]: trait takes 2 lifetime arguments but 1 lifetime argument was supplied
   --> src/convertor/python.rs:89:11
    |
 89 | impl<'py> FromPyObject<'py> for SafeManagedTensorVersioned {
    |           ^^^^^^^^^^^^ --- supplied 1 lifetime argument
    |           |
    |           expected 2 lifetime arguments
    |
note: trait defined here, with 2 lifetime parameters: `'a`, `'py`
   --> /home/user/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/pyo3-0.27.1/src/conversion.rs:376:11
    |
376 | pub trait FromPyObject<'a, 'py>: Sized {
    |           ^^^^^^^^^^^^ --  ---
help: add missing lifetime argument
    |
 89 | impl<'py> FromPyObject<'py, 'py> for SafeManagedTensorVersioned {
    |                           +++++

Some errors have detailed explanations: E0107, E0407.
For more information about an error, try `rustc --explain E0107`.
error: could not compile `dlpark` (lib) due to 4 previous errors
warning: build failed, waiting for other jobs to finish...
error[E0599]: no function or associated item named `extract_bound` found for struct `legacy::safe_managed_tensor::SafeManagedTensor` in the current scope
   --> src/convertor/python.rs:128:42
    |
128 |             let mt2 = SafeManagedTensor::extract_bound(&capsule).expect("fail to extract bound");
    |                                          ^^^^^^^^^^^^^ function or associated item not found in `legacy::safe_managed_tensor::SafeManagedTensor`
    |
   ::: src/legacy/safe_managed_tensor.rs:11:1
    |
 11 | pub struct SafeManagedTensor(ffi::Dlpack);
    | ---------------------------- function or associated item `extract_bound` not found for this struct
    |
note: if you're trying to build a new `legacy::safe_managed_tensor::SafeManagedTensor` consider using one of the following associated functions:
      legacy::safe_managed_tensor::SafeManagedTensor::new
      legacy::safe_managed_tensor::SafeManagedTensor::from_raw
      legacy::safe_managed_tensor::SafeManagedTensor::from_non_null
   --> src/legacy/safe_managed_tensor.rs:35:5
    |
 35 | /     pub fn new<T, L>(t: T) -> std::result::Result<Self, T::Error>
 36 | |     where
 37 | |         T: TensorLike<L>,
 38 | |         L: MemoryLayout,
    | |________________________^
...
 51 |       pub unsafe fn from_raw(ptr: *mut ffi::ManagedTensor) -> Self {
    |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
 60 |       pub unsafe fn from_non_null(ptr: ffi::Dlpack) -> Self {
    |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

error[E0599]: no function or associated item named `extract_bound` found for struct `versioned::safe_managed_tensor::SafeManagedTensorVersioned` in the current scope
   --> src/convertor/python.rs:142:45
    |
142 |                 SafeManagedTensorVersioned::extract_bound(&capsule).expect("fail to extract bound");
    |                                             ^^^^^^^^^^^^^ function or associated item not found in `versioned::safe_managed_tensor::SafeManagedTensorVersioned`
    |
   ::: src/versioned/safe_managed_tensor.rs:13:1
    |
 13 | pub struct SafeManagedTensorVersioned(ffi::DlpackVersioned);
    | ------------------------------------- function or associated item `extract_bound` not found for this struct
    |
note: if you're trying to build a new `versioned::safe_managed_tensor::SafeManagedTensorVersioned` consider using one of the following associated functions:
      versioned::safe_managed_tensor::SafeManagedTensorVersioned::new
      versioned::safe_managed_tensor::SafeManagedTensorVersioned::with_flags
      versioned::safe_managed_tensor::SafeManagedTensorVersioned::from_raw
      versioned::safe_managed_tensor::SafeManagedTensorVersioned::from_non_null
   --> src/versioned/safe_managed_tensor.rs:35:5
    |
 35 | /     pub fn new<T, L>(t: T) -> std::result::Result<Self, T::Error>
 36 | |     where
 37 | |         T: TensorLike<L>,
 38 | |         L: MemoryLayout,
    | |________________________^
...
 51 | /     pub fn with_flags<T, L>(t: T, flags: Flags) -> std::result::Result<Self, T::Error>
 52 | |     where
 53 | |         T: TensorLike<L>,
 54 | |         L: MemoryLayout,
    | |________________________^
...
 67 |       pub unsafe fn from_raw(ptr: *mut ffi::ManagedTensorVersioned) -> Self {
    |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
 77 |       pub unsafe fn from_non_null(ptr: ffi::DlpackVersioned) -> Self {
    |       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Some errors have detailed explanations: E0107, E0407, E0599.
error: could not compile `dlpark` (lib test) due to 6 previous errors

@weiji14 weiji14 marked this pull request as ready for review October 24, 2025 11:02
Copy link
Copy Markdown
Owner

@SunDoge SunDoge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@SunDoge SunDoge merged commit 1625cae into SunDoge:main Nov 3, 2025
1 check passed
@weiji14 weiji14 deleted the pyo3-0.27 branch November 3, 2025 19:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants