Skip to content

Commit add5aa6

Browse files
committed
update PyO3 0.27
1 parent 283f122 commit add5aa6

File tree

14 files changed

+100
-101
lines changed

14 files changed

+100
-101
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
# Changelog
2+
- v0.27.0
3+
- Bump PyO3 dependency to v0.27.0. ([#xxx](https://github.com/PyO3/rust-numpy/pull/xxx))
4+
25
- v0.26.0
36
- bump MSRV to 1.74, matching PyO3 ([#504](https://github.com/PyO3/rust-numpy/pull/504))
47
- extend supported `nalgebra` version to `0.34` ([#503](https://github.com/PyO3/rust-numpy/pull/503))

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "numpy"
3-
version = "0.26.0"
3+
version = "0.27.0"
44
authors = [
55
"The rust-numpy Project Developers",
66
"PyO3 Project and Contributors <https://github.com/PyO3>",
@@ -22,13 +22,13 @@ num-complex = ">= 0.2, < 0.5"
2222
num-integer = "0.1"
2323
num-traits = "0.2"
2424
ndarray = ">= 0.15, < 0.17"
25-
pyo3 = { version = "0.26.0", default-features = false, features = ["macros"]}
25+
pyo3 = { version = "0.26.0", default-features = false, features = ["macros"], git = "https://github.com/PyO3/pyo3" }
2626
rustc-hash = "2.0"
2727

2828
[dev-dependencies]
2929
pyo3 = { version = "0.26.0", default-features = false, features = [
3030
"auto-initialize",
31-
] }
31+
], git = "https://github.com/PyO3/pyo3" }
3232
nalgebra = { version = ">=0.30, <0.35", default-features = false, features = [
3333
"std",
3434
] }

README.md

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ rust-numpy
22
===========
33
[![Actions Status](https://github.com/PyO3/rust-numpy/workflows/CI/badge.svg)](https://github.com/PyO3/rust-numpy/actions)
44
[![Crate](https://img.shields.io/crates/v/numpy.svg)](https://crates.io/crates/numpy)
5-
[![Minimum rustc 1.63](https://img.shields.io/badge/rustc-1.63+-blue.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html)
5+
[![Minimum rustc 1.74](https://img.shields.io/badge/rustc-1.74+-blue.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html)
66
[![Documentation](https://docs.rs/numpy/badge.svg)](https://docs.rs/numpy)
77
[![codecov](https://codecov.io/gh/PyO3/rust-numpy/branch/main/graph/badge.svg)](https://codecov.io/gh/PyO3/rust-numpy)
88

@@ -13,7 +13,7 @@ Rust bindings for the NumPy C-API.
1313
- [Current main](https://pyo3.github.io/rust-numpy)
1414

1515
## Requirements
16-
- Rust >= 1.63.0
16+
- Rust >= 1.74.0
1717
- Basically, our MSRV follows the one of [PyO3](https://github.com/PyO3/pyo3)
1818
- Python >= 3.7
1919
- Python 3.6 support was dropped from 0.16
@@ -38,17 +38,17 @@ name = "rust_ext"
3838
crate-type = ["cdylib"]
3939

4040
[dependencies]
41-
pyo3 = { version = "0.22", features = ["extension-module"] }
42-
numpy = "0.22"
41+
pyo3 = { version = "0.27", features = ["extension-module"] }
42+
numpy = "0.27"
4343
```
4444

4545
```rust
46-
use numpy::ndarray::{ArrayD, ArrayViewD, ArrayViewMutD};
47-
use numpy::{IntoPyArray, PyArrayDyn, PyReadonlyArrayDyn, PyArrayMethods};
48-
use pyo3::{pymodule, types::PyModule, PyResult, Python, Bound};
46+
#[pyo3::pymodule]
47+
mod rust_ext {
48+
use numpy::ndarray::{ArrayD, ArrayViewD, ArrayViewMutD};
49+
use numpy::{IntoPyArray, PyArrayDyn, PyReadonlyArrayDyn, PyArrayMethods};
50+
use pyo3::{pyfunction, PyResult, Python, Bound};
4951

50-
#[pymodule]
51-
fn rust_ext<'py>(_py: Python<'py>, m: &Bound<'py, PyModule>) -> PyResult<()> {
5252
// example using immutable borrows producing a new array
5353
fn axpy(a: f64, x: ArrayViewD<'_, f64>, y: ArrayViewD<'_, f64>) -> ArrayD<f64> {
5454
a * &x + &y
@@ -60,8 +60,7 @@ fn rust_ext<'py>(_py: Python<'py>, m: &Bound<'py, PyModule>) -> PyResult<()> {
6060
}
6161

6262
// wrapper of `axpy`
63-
#[pyfn(m)]
64-
#[pyo3(name = "axpy")]
63+
#[pyfunction(name = "axpy")]
6564
fn axpy_py<'py>(
6665
py: Python<'py>,
6766
a: f64,
@@ -75,14 +74,11 @@ fn rust_ext<'py>(_py: Python<'py>, m: &Bound<'py, PyModule>) -> PyResult<()> {
7574
}
7675

7776
// wrapper of `mult`
78-
#[pyfn(m)]
79-
#[pyo3(name = "mult")]
77+
#[pyfunction(name = "mult")]
8078
fn mult_py<'py>(a: f64, x: &Bound<'py, PyArrayDyn<f64>>) {
8179
let x = unsafe { x.as_array_mut() };
8280
mult(a, x);
8381
}
84-
85-
Ok(())
8682
}
8783
```
8884

@@ -93,8 +89,8 @@ fn rust_ext<'py>(_py: Python<'py>, m: &Bound<'py, PyModule>) -> PyResult<()> {
9389
name = "numpy-test"
9490

9591
[dependencies]
96-
pyo3 = { version = "0.22", features = ["auto-initialize"] }
97-
numpy = "0.22"
92+
pyo3 = { version = "0.27", features = ["auto-initialize"] }
93+
numpy = "0.27"
9894
```
9995

10096
```rust
@@ -132,7 +128,7 @@ on anything but that exact range. It can therefore be necessary to manually unif
132128
For example, if you specify the following dependencies
133129

134130
```toml
135-
numpy = "0.22"
131+
numpy = "0.27"
136132
ndarray = "0.15"
137133
```
138134

benches/array.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ fn extract_success(bencher: &mut Bencher) {
2424
#[bench]
2525
fn extract_failure(bencher: &mut Bencher) {
2626
Python::attach(|py| {
27-
let any = PyArray2::<f64>::zeros(py, (10, 10), false).into_any();
27+
let any = PyArray2::<i32>::zeros(py, (10, 10), false).into_any();
2828

2929
bencher.iter(|| {
3030
black_box(&any)
@@ -46,7 +46,7 @@ fn cast_success(bencher: &mut Bencher) {
4646
#[bench]
4747
fn cast_failure(bencher: &mut Bencher) {
4848
Python::attach(|py| {
49-
let any = PyArray2::<f64>::zeros(py, (10, 10), false).into_any();
49+
let any = PyArray2::<i32>::zeros(py, (10, 10), false).into_any();
5050

5151
bencher.iter(|| black_box(&any).cast::<PyArray2<f64>>().unwrap_err());
5252
});

examples/linalg/Cargo.lock

Lines changed: 11 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/linalg/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ name = "rust_linalg"
99
crate-type = ["cdylib"]
1010

1111
[dependencies]
12-
pyo3 = { version = "0.26.0", features = ["extension-module"] }
12+
pyo3 = { version = "0.26.0", features = ["extension-module"], git = "https://github.com/PyO3/pyo3" }
1313
numpy = { path = "../.." }
1414
ndarray-linalg = { version = "0.14.1", features = ["openblas-system"] }
1515

examples/linalg/src/lib.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use ndarray_linalg::solve::Inverse;
2-
use numpy::{IntoPyArray, PyArray2, PyReadonlyArray2};
3-
use pyo3::{exceptions::PyRuntimeError, pymodule, types::PyModule, Bound, PyResult, Python};
1+
#[pyo3::pymodule]
2+
mod rust_linalg {
3+
use ndarray_linalg::solve::Inverse;
4+
use numpy::{IntoPyArray, PyArray2, PyReadonlyArray2};
5+
use pyo3::{exceptions::PyRuntimeError, pyfunction, Bound, PyResult, Python};
46

5-
#[pymodule]
6-
fn rust_linalg<'py>(m: &Bound<'py, PyModule>) -> PyResult<()> {
7-
#[pyfn(m)]
7+
#[pyfunction]
88
fn inv<'py>(
99
py: Python<'py>,
1010
x: PyReadonlyArray2<'py, f64>,
@@ -15,5 +15,4 @@ fn rust_linalg<'py>(m: &Bound<'py, PyModule>) -> PyResult<()> {
1515
.map_err(|e| PyRuntimeError::new_err(e.to_string()))?;
1616
Ok(y.into_pyarray(py))
1717
}
18-
Ok(())
1918
}

examples/parallel/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ name = "rust_parallel"
99
crate-type = ["cdylib"]
1010

1111
[dependencies]
12-
pyo3 = { version = "0.26.0", features = ["extension-module", "multiple-pymethods"] }
12+
pyo3 = { version = "0.26.0", features = ["extension-module", "multiple-pymethods"], git = "https://github.com/PyO3/pyo3" }
1313
numpy = { path = "../.." }
1414
ndarray = { version = "0.16", features = ["rayon", "blas"] }
1515
blas-src = { version = "0.8", features = ["openblas"] }

examples/parallel/src/lib.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// We need to link `blas_src` directly, c.f. https://github.com/rust-ndarray/ndarray#how-to-enable-blas-integration
22
extern crate blas_src;
33

4-
use numpy::ndarray::Zip;
5-
use numpy::{IntoPyArray, PyArray1, PyReadonlyArray1, PyReadonlyArray2};
6-
use pyo3::{pymodule, types::PyModule, Bound, PyResult, Python};
4+
#[pyo3::pymodule]
5+
mod rust_parallel {
6+
use numpy::ndarray::Zip;
7+
use numpy::{IntoPyArray, PyArray1, PyReadonlyArray1, PyReadonlyArray2};
8+
use pyo3::{pyfunction, Bound, PyResult, Python};
79

8-
#[pymodule]
9-
fn rust_parallel<'py>(m: &Bound<'py, PyModule>) -> PyResult<()> {
10-
#[pyfn(m)]
10+
#[pyfunction]
1111
fn rows_dot<'py>(
1212
py: Python<'py>,
1313
x: PyReadonlyArray2<'py, f64>,
@@ -18,5 +18,4 @@ fn rust_parallel<'py>(m: &Bound<'py, PyModule>) -> PyResult<()> {
1818
let z = Zip::from(x.rows()).par_map_collect(|row| row.dot(&y));
1919
z.into_pyarray(py)
2020
}
21-
Ok(())
2221
}

examples/simple/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ name = "rust_ext"
99
crate-type = ["cdylib"]
1010

1111
[dependencies]
12-
pyo3 = { version = "0.26.0", features = ["extension-module", "abi3-py37"] }
12+
pyo3 = { version = "0.26.0", features = ["extension-module", "abi3-py37"], git = "https://github.com/PyO3/pyo3" }
1313
numpy = { path = "../.." }
1414

1515
[workspace]

0 commit comments

Comments
 (0)