Skip to content

Commit

Permalink
Upgrade pyo3 to 0.20
Browse files Browse the repository at this point in the history
  • Loading branch information
messense authored and adamreichold committed Oct 12, 2023
1 parent 1671b00 commit 53f7499
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ num-complex = ">= 0.2, < 0.5"
num-integer = "0.1"
num-traits = "0.2"
ndarray = ">= 0.13, < 0.16"
pyo3 = { version = "0.19", default-features = false, features = ["macros"] }
pyo3 = { version = "0.20", default-features = false, features = ["macros"] }
rustc-hash = "1.1"

[dev-dependencies]
pyo3 = { version = "0.19", default-features = false, features = ["auto-initialize"] }
pyo3 = { version = "0.20", default-features = false, features = ["auto-initialize"] }
nalgebra = { version = "0.32", default-features = false, features = ["std"] }

[package.metadata.docs.rs]
Expand Down
2 changes: 1 addition & 1 deletion examples/linalg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name = "rust_linalg"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.19", features = ["extension-module"] }
pyo3 = { version = "0.20", features = ["extension-module"] }
numpy = { path = "../.." }
ndarray-linalg = { version = "0.14.1", features = ["openblas-system"] }

Expand Down
2 changes: 1 addition & 1 deletion examples/linalg/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build-system]
build-backend = "maturin"
requires = ["maturin>=0.13,<0.14"]
requires = ["maturin>=1.0,<2.0"]
2 changes: 1 addition & 1 deletion examples/parallel/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name = "rust_parallel"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.19", features = ["extension-module", "multiple-pymethods"] }
pyo3 = { version = "0.20", features = ["extension-module", "multiple-pymethods"] }
numpy = { path = "../.." }
ndarray = { version = "0.15", features = ["rayon", "blas"] }
blas-src = { version = "0.8", features = ["openblas"] }
Expand Down
2 changes: 1 addition & 1 deletion examples/parallel/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build-system]
build-backend = "maturin"
requires = ["maturin>=0.13,<0.14"]
requires = ["maturin>=1.0,<2.0"]
2 changes: 1 addition & 1 deletion examples/simple/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ name = "rust_ext"
crate-type = ["cdylib"]

[dependencies]
pyo3 = { version = "0.19", features = ["extension-module", "abi3-py37"] }
pyo3 = { version = "0.20", features = ["extension-module", "abi3-py37"] }
numpy = { path = "../.." }

[workspace]
2 changes: 1 addition & 1 deletion examples/simple/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[build-system]
build-backend = "maturin"
requires = ["maturin>=0.13,<0.14"]
requires = ["maturin>=1.0,<2.0"]
1 change: 1 addition & 0 deletions examples/simple/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ fn rust_ext<'py>(_py: Python<'py>, m: &'py PyModule) -> PyResult<()> {
let x = d
.get_item("x")
.unwrap()
.unwrap()
.downcast::<PyArray1<f64>>()
.unwrap();

Expand Down
2 changes: 1 addition & 1 deletion src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ impl<T, D> Deref for PyArray<T, D> {
}
}

impl<T, D> AsPyPointer for PyArray<T, D> {
unsafe impl<T, D> AsPyPointer for PyArray<T, D> {
#[inline]
fn as_ptr(&self) -> *mut ffi::PyObject {
self.0.as_ptr()
Expand Down
8 changes: 5 additions & 3 deletions src/dtype.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use pyo3::{
ffi::{self, PyTuple_Size},
pyobject_native_type_extract, pyobject_native_type_named,
types::{PyDict, PyTuple, PyType},
AsPyPointer, FromPyObject, FromPyPointer, IntoPyPointer, PyAny, PyNativeType, PyObject,
PyResult, PyTypeInfo, Python, ToPyObject,
AsPyPointer, FromPyObject, FromPyPointer, PyAny, PyNativeType, PyObject, PyResult, PyTypeInfo,
Python, ToPyObject,
};
#[cfg(feature = "half")]
use pyo3::{sync::GILOnceCell, IntoPy, Py};
Expand Down Expand Up @@ -352,7 +352,7 @@ impl PyArrayDescr {
let dict = unsafe { PyDict::from_borrowed_ptr(self.py(), (*self.as_dtype_ptr()).fields) };
// NumPy guarantees that fields are tuples of proper size and type, so this should never panic.
let tuple = dict
.get_item(name)
.get_item(name)?
.ok_or_else(|| PyIndexError::new_err(name.to_owned()))?
.downcast::<PyTuple>()
.unwrap();
Expand Down Expand Up @@ -609,6 +609,7 @@ mod tests {
let dt = locals
.get_item("dtype")
.unwrap()
.unwrap()
.downcast::<PyArrayDescr>()
.unwrap();

Expand Down Expand Up @@ -644,6 +645,7 @@ mod tests {
let dt = locals
.get_item("dtype")
.unwrap()
.unwrap()
.downcast::<PyArrayDescr>()
.unwrap();

Expand Down

0 comments on commit 53f7499

Please sign in to comment.