Skip to content

Commit 3850501

Browse files
committed
Bump PyO3 version to 0.14
This implies an API change due to re-exported types from PyO3.
1 parent 696c77b commit 3850501

File tree

7 files changed

+23
-32
lines changed

7 files changed

+23
-32
lines changed

Cargo.toml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "numpy"
3-
version = "0.13.2"
3+
version = "0.14.0"
44
authors = [
55
"Toshiki Teramura <toshiki.teramura@gmail.com>",
66
"Yuji Kanagawa <yuji.kngw.80s.revive@gmail.com>",
@@ -19,15 +19,15 @@ libc = "0.2"
1919
num-complex = ">= 0.2, <= 0.4"
2020
num-traits = "0.2"
2121
ndarray = ">= 0.13, < 0.16"
22-
pyo3 = { version = "0.13", default-features = false }
22+
pyo3 = { version = "0.14", default-features = false }
2323

2424
[dev-dependencies]
25-
pyo3 = "0.13"
25+
pyo3 = { version = "0.14", features = ["auto-initialize"] }
2626

2727
[features]
2828
# In default setting, python version is automatically detected
2929
default = []
3030
rayon = ["ndarray/rayon"]
3131

3232
[workspace]
33-
members = ["examples/*"]
33+
members = ["examples/*"]

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ using [setuptools-rust](https://github.com/PyO3/setuptools-rust).
5555
name = "numpy-test"
5656

5757
[dependencies]
58-
pyo3 = "0.13"
59-
numpy = "0.13"
58+
pyo3 = "0.14"
59+
numpy = "0.14"
6060
```
6161

6262
```rust
@@ -92,11 +92,11 @@ name = "rust_ext"
9292
crate-type = ["cdylib"]
9393

9494
[dependencies]
95-
numpy = "0.13"
95+
numpy = "0.14"
9696
ndarray = "0.14"
9797

9898
[dependencies.pyo3]
99-
version = "0.13"
99+
version = "0.14"
100100
features = ["extension-module"]
101101
```
102102

examples/linalg/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,5 @@ ndarray = "0.15"
1515
ndarray-linalg = { git = "https://github.com/rust-ndarray/ndarray-linalg", features = ["openblas-static"] }
1616

1717
[dependencies.pyo3]
18-
version = "0.13"
18+
version = "0.14"
1919
features = ["extension-module"]

examples/simple-extension/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,5 @@ ndarray = "0.15.2"
1414
num-complex = "0.4.0"
1515

1616
[dependencies.pyo3]
17-
version = "0.13"
17+
version = "0.14"
1818
features = ["extension-module"]

src/array.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,9 @@ impl<T, D> type_object::PySizedLayout<PyArray<T, D>> for npyffi::PyArrayObject {
104104

105105
pyobject_native_type_info!(
106106
PyArray<T, D>,
107-
npyffi::PyArrayObject,
108107
*npyffi::PY_ARRAY_API.get_type_object(npyffi::NpyTypes::PyArray_Type),
109108
Some("numpy"),
110-
npyffi::PyArray_Check
109+
#checkfunction=npyffi::PyArray_Check
111110
; T
112111
; D
113112
);

src/dtype.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,9 @@ pub struct PyArrayDescr(PyAny);
2626

2727
pyobject_native_type_core!(
2828
PyArrayDescr,
29-
PyArray_Descr,
3029
*PY_ARRAY_API.get_type_object(NpyTypes::PyArrayDescr_Type),
31-
Some("numpy"),
32-
arraydescr_check
30+
#module=Some("numpy"),
31+
#checkfunction=arraydescr_check
3332
);
3433

3534
unsafe fn arraydescr_check(op: *mut ffi::PyObject) -> c_int {

src/slice_box.rs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use pyo3::class::{methods::PyMethods, proto_methods::PyProtoMethods};
2-
use pyo3::pyclass::{PyClass, PyClassAlloc, PyClassSend, ThreadCheckerStub};
1+
use pyo3::class::impl_::{PyClassImpl, ThreadCheckerStub};
2+
use pyo3::pyclass::PyClass;
33
use pyo3::pyclass_slots::PyClassDummySlot;
4-
use pyo3::{ffi, type_object, types::PyAny, PyCell, PyClassInitializer};
4+
use pyo3::{ffi, type_object, types::PyAny, PyCell};
55

66
pub(crate) struct SliceBox<T> {
77
pub(crate) data: *mut [T],
@@ -21,25 +21,24 @@ impl<T> Drop for SliceBox<T> {
2121
}
2222
}
2323

24-
impl<T> PyClassAlloc for SliceBox<T> {}
25-
2624
impl<T> PyClass for SliceBox<T> {
2725
type Dict = PyClassDummySlot;
2826
type WeakRef = PyClassDummySlot;
2927
type BaseNativeType = PyAny;
3028
}
3129

32-
unsafe impl<T> type_object::PyTypeInfo for SliceBox<T> {
33-
type Type = ();
30+
impl<T> PyClassImpl for SliceBox<T> {
31+
const DOC: &'static str = "Memory store for PyArray using rust's Box<[T]> \0";
32+
3433
type BaseType = PyAny;
35-
type BaseLayout = pyo3::pycell::PyCellBase<PyAny>;
3634
type Layout = PyCell<Self>;
37-
type Initializer = PyClassInitializer<Self>;
35+
type ThreadChecker = ThreadCheckerStub<Self>;
36+
}
37+
38+
unsafe impl<T> type_object::PyTypeInfo for SliceBox<T> {
3839
type AsRefTarget = PyCell<Self>;
3940
const NAME: &'static str = "SliceBox";
4041
const MODULE: Option<&'static str> = Some("_rust_numpy");
41-
const DESCRIPTION: &'static str = "Memory store for PyArray using rust's Box<[T]> \0";
42-
const FLAGS: usize = 0;
4342

4443
#[inline]
4544
fn type_object_raw(py: pyo3::Python) -> *mut ffi::PyTypeObject {
@@ -49,10 +48,4 @@ unsafe impl<T> type_object::PyTypeInfo for SliceBox<T> {
4948
}
5049
}
5150

52-
// Some stubs to use PyClass
53-
impl<T> PyMethods for SliceBox<T> {}
54-
impl<T> PyProtoMethods for SliceBox<T> {}
5551
unsafe impl<T> Send for SliceBox<T> {}
56-
impl<T> PyClassSend for SliceBox<T> {
57-
type ThreadChecker = ThreadCheckerStub<Self>;
58-
}

0 commit comments

Comments
 (0)