Skip to content

Commit 4ef0102

Browse files
authored
Updated to PyO3 version 0.29.0 (#553)
* Updated to latest PyO3 version, fixed deprecation, updated README and examples. * Removed Python versions 3.7 and 3.13t that are no longer supported. * update CHANGELOG heading, incresed nalgebra version range to include 0.35
1 parent edec058 commit 4ef0102

8 files changed

Lines changed: 24 additions & 45 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,12 @@ jobs:
3232
matrix:
3333
python-version:
3434
[
35-
"3.7",
3635
"3.8",
3736
"3.9",
3837
"3.10",
3938
"3.11",
4039
"3.12",
4140
"3.13",
42-
"3.13t",
4341
"3.14",
4442
"3.14t",
4543
"pypy-3.11",
@@ -68,23 +66,11 @@ jobs:
6866
},
6967
]
7068
include:
71-
# ubuntu-24.04 does not support 3.7
72-
- python-version: 3.7
73-
platform: { os: "ubuntu-22.04", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" }
74-
# not available on arm64 macOS, test on x64
75-
- python-version: 3.7
76-
platform: { os: "macos-15-intel", python-architecture: "x64", rust-target: "x86_64-apple-darwin" }
7769
- python-version: 3.8
7870
platform: { os: "macos-15-intel", python-architecture: "x64", rust-target: "x86_64-apple-darwin" }
7971
- python-version: 3.9
8072
platform: { os: "macos-15-intel", python-architecture: "x64", rust-target: "x86_64-apple-darwin" }
8173
exclude:
82-
# ubuntu-24.04 does not support 3.7
83-
- python-version: 3.7
84-
platform: { os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" }
85-
# not available on arm64 macOS
86-
- python-version: 3.7
87-
platform: { os: "macOS-latest", python-architecture: "arm64", rust-target: "aarch64-apple-darwin" }
8874
- python-version: 3.8
8975
platform: { os: "macOS-latest", python-architecture: "arm64", rust-target: "aarch64-apple-darwin" }
9076
- python-version: 3.9
@@ -125,7 +111,7 @@ jobs:
125111
strategy:
126112
fail-fast: ${{ !contains(github.event.pull_request.labels.*.name, 'CI-no-fail-fast') }}
127113
matrix:
128-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11", "3.12"] # last numpy 1 release for 3.12
114+
python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] # last numpy 1 release for 3.12
129115
platform:
130116
[
131117
{
@@ -150,23 +136,11 @@ jobs:
150136
},
151137
]
152138
include:
153-
# ubuntu-24.04 does not support 3.7
154-
- python-version: 3.7
155-
platform: { os: "ubuntu-22.04", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" }
156-
# not available on arm64 macOS, test on x64
157-
- python-version: 3.7
158-
platform: { os: "macos-15-intel", python-architecture: "x64", rust-target: "x86_64-apple-darwin" }
159139
- python-version: 3.8
160140
platform: { os: "macos-15-intel", python-architecture: "x64", rust-target: "x86_64-apple-darwin" }
161141
- python-version: 3.9
162142
platform: { os: "macos-15-intel", python-architecture: "x64", rust-target: "x86_64-apple-darwin" }
163143
exclude:
164-
# ubuntu-24.04 does not support 3.7
165-
- python-version: 3.7
166-
platform: { os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" }
167-
# not available on arm64 macOS
168-
- python-version: 3.7
169-
platform: { os: "macOS-latest", python-architecture: "arm64", rust-target: "aarch64-apple-darwin" }
170144
- python-version: 3.8
171145
platform: { os: "macOS-latest", python-architecture: "arm64", rust-target: "aarch64-apple-darwin" }
172146
- python-version: 3.9

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
# Changelog
22

33
- Unreleased
4+
5+
- v0.29.0
46
- Fix PyArray_DTypeMeta definition when Py_LIMITED_API is disabled ([#532](https://github.com/PyO3/rust-numpy/pull/532))
57
- The NumPy C API binding has been updated to target the ABI v2, while maintaining runtime compatibility with NumPy v1 targeting the API v1.15. The higher interface is unchanged. ([#537](https://github.com/PyO3/rust-numpy/pull/537))
68
- Fix `is_exact_type_of` / `cast_exact` to use `PyArray_CheckExact` instead of `PyArray_Check`, correctly rejecting subclasses of `ndarray`. ([#550](https://github.com/PyO3/rust-numpy/pull/550))
9+
- Bump PyO3 dependency to v0.29.0 ([#553](https://github.com/PyO3/rust-numpy/pull/553))
10+
- Fix `PyCapsule::new_with_destructor` to use `PyCapsule::new_with_value_and_destructor`.
11+
- Open `nalgebra` range to include 0.35.
712

813
- v0.28.0
914
- Fix mismatched behavior between `PyArrayLike1` and `PyArrayLike2` when used with floats ([#520](https://github.com/PyO3/rust-numpy/pull/520))

Cargo.toml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "numpy"
3-
version = "0.28.0"
3+
version = "0.29.0"
44
authors = [
55
"The rust-numpy Project Developers",
66
"PyO3 Project and Contributors <https://github.com/PyO3>",
@@ -23,21 +23,21 @@ exclude = [
2323
[dependencies]
2424
half = { version = "2.0", default-features = false, optional = true }
2525
libc = "0.2"
26-
nalgebra = { version = ">=0.30, <0.35", default-features = false, optional = true }
26+
nalgebra = { version = ">=0.30, <=0.35", default-features = false, optional = true }
2727
num-complex = ">= 0.2, < 0.5"
2828
num-integer = "0.1"
2929
num-traits = "0.2"
3030
ndarray = ">= 0.15, <=0.17"
31-
pyo3 = { version = "0.28.0", default-features = false, features = ["macros"] }
31+
pyo3 = { version = "0.29.0", default-features = false, features = ["macros"] }
3232
rustc-hash = "2.0"
3333

3434
[dev-dependencies]
35-
pyo3 = { version = "0.28.0", default-features = false, features = ["auto-initialize"]}
35+
pyo3 = { version = "0.29.0", default-features = false, features = ["auto-initialize"]}
3636
nalgebra = { version = ">=0.30, <0.35", default-features = false, features = ["std"] }
3737
criterion = "0.8.2"
3838

3939
[build-dependencies]
40-
pyo3-build-config = { version = "0.28", features = ["resolve-config"]}
40+
pyo3-build-config = { version = "0.29", features = ["resolve-config"]}
4141

4242
[[bench]]
4343
name = "array"

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ Rust bindings for the NumPy C-API.
1515
## Requirements
1616
- Rust >= 1.83.0
1717
- Basically, our MSRV follows the one of [PyO3](https://github.com/PyO3/pyo3)
18-
- Python >= 3.7
19-
- Python 3.6 support was dropped from 0.16
18+
- Python >= 3.8
19+
- Python 3.7 support was dropped from 0.29
2020
- Some Rust libraries
2121
- [ndarray](https://github.com/rust-ndarray/ndarray) for Rust-side matrix library
2222
- [PyO3](https://github.com/PyO3/pyo3) for Python bindings
@@ -38,8 +38,8 @@ name = "rust_ext"
3838
crate-type = ["cdylib"]
3939

4040
[dependencies]
41-
pyo3 = { version = "0.27" }
42-
numpy = "0.27"
41+
pyo3 = { version = "0.29" }
42+
numpy = "0.29"
4343
```
4444

4545
```rust
@@ -89,8 +89,8 @@ mod rust_ext {
8989
name = "numpy-test"
9090

9191
[dependencies]
92-
pyo3 = { version = "0.27", features = ["auto-initialize"] }
93-
numpy = "0.27"
92+
pyo3 = { version = "0.29", features = ["auto-initialize"] }
93+
numpy = "0.29"
9494
```
9595

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

130130
```toml
131-
numpy = "0.27"
131+
numpy = "0.29"
132132
ndarray = "0.15"
133133
```
134134

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.28.0" }
12+
pyo3 = { version = "0.29.0" }
1313
numpy = { path = "../.." }
1414
ndarray-linalg = { version = "0.14.1", features = ["openblas-system"] }
1515

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.28.0", features = ["multiple-pymethods"] }
12+
pyo3 = { version = "0.29.0", features = ["multiple-pymethods"] }
1313
numpy = { path = "../.." }
1414
ndarray = { version = "0.17", features = ["rayon", "blas"] }
1515
blas-src = { version = "0.8", features = ["openblas"] }

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.28.0", features = ["abi3-py37"] }
12+
pyo3 = { version = "0.29.0", features = ["abi3-py38"] }
1313
numpy = { path = "../.." }
1414

1515
[workspace]

src/borrow/shared.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::collections::hash_map::Entry;
2-
use std::ffi::{c_char, c_int, c_void, CString};
2+
use std::ffi::{c_char, c_int, c_void};
33
use std::mem::forget;
44
use std::ptr::NonNull;
55
use std::slice::from_raw_parts;
@@ -135,10 +135,10 @@ fn insert_shared<'py>(py: Python<'py>) -> PyResult<NonNull<Shared>> {
135135
release_mut: release_mut_shared,
136136
};
137137

138-
let capsule = PyCapsule::new_with_destructor(
138+
let capsule = PyCapsule::new_with_value_and_destructor(
139139
py,
140140
shared,
141-
Some(CString::new("_RUST_NUMPY_BORROW_CHECKING_API").unwrap()),
141+
c"_RUST_NUMPY_BORROW_CHECKING_API",
142142
|shared, _ctx| {
143143
// SAFETY: `shared.flags` was initialized using `Box::into_raw`.
144144
let _ = unsafe { Box::from_raw(shared.flags as *mut BorrowFlags) };

0 commit comments

Comments
 (0)