Skip to content

Commit fadd273

Browse files
committed
Fix imports
1 parent cbbb4bf commit fadd273

File tree

10 files changed

+31
-31
lines changed

10 files changed

+31
-31
lines changed

example/extensions/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11

22
#[macro_use]
3-
extern crate cpython;
3+
extern crate pyo3;
44
extern crate numpy;
55
extern crate ndarray;
66

77
use numpy::*;
88
use ndarray::*;
9-
use cpython::{PyResult, Python, PyObject};
9+
use pyo3::{PyResult, Python, PyObject};
1010

1111
/* Pure rust-ndarray functions */
1212

@@ -20,7 +20,7 @@ fn mult(a: f64, mut x: ArrayViewMutD<f64>) {
2020
x *= a;
2121
}
2222

23-
/* rust-cpython wrappers (to be exposed) */
23+
/* rust-pyo3 wrappers (to be exposed) */
2424

2525
// wrapper of `axpy`
2626
fn axpy_py(py: Python, a: f64, x: PyArray, y: PyArray) -> PyResult<PyArray> {

src/array.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
//! Untyped safe interface for NumPy ndarray
22
3-
use cpython::*;
43
use ndarray::*;
54
use npyffi;
6-
use pyffi;
5+
use pyo3::ffi;
6+
use pyo3::*;
77

88
use std::os::raw::c_void;
99
use std::ptr::null_mut;
@@ -23,12 +23,12 @@ impl PyArray {
2323
self.0.steal_ptr() as *mut npyffi::PyArrayObject
2424
}
2525

26-
pub unsafe fn from_owned_ptr(py: Python, ptr: *mut pyffi::PyObject) -> Self {
26+
pub unsafe fn from_owned_ptr(py: Python, ptr: *mut pyo3::ffi::PyObject) -> Self {
2727
let obj = PyObject::from_owned_ptr(py, ptr);
2828
PyArray(obj)
2929
}
3030

31-
pub unsafe fn from_borrowed_ptr(py: Python, ptr: *mut pyffi::PyObject) -> Self {
31+
pub unsafe fn from_borrowed_ptr(py: Python, ptr: *mut pyo3::ffi::PyObject) -> Self {
3232
let obj = PyObject::from_borrowed_ptr(py, ptr);
3333
PyArray(obj)
3434
}

src/convert.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use cpython::Python;
21
use ndarray::*;
2+
use pyo3::Python;
33

44
use std::iter::Iterator;
55
use std::mem::size_of;

src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Define Errors
22
3-
use cpython::*;
3+
use pyo3::*;
44
use std::error;
55
use std::fmt;
66

src/npyffi/array.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ use std::ops::Deref;
77
use std::os::raw::*;
88
use std::ptr::null_mut;
99

10-
use cpython::{ObjectProtocol, PyModule, PyResult, Python, PythonObject};
11-
use pyffi;
12-
use pyffi::{PyObject, PyTypeObject};
10+
use pyo3::ffi;
11+
use pyo3::ffi::{PyObject, PyTypeObject};
12+
use pyo3::{ObjectProtocol, PyModule, PyResult, Python};
1313

1414
use npyffi::*;
1515

@@ -48,7 +48,7 @@ impl PyArrayModule {
4848
let numpy = py.import("numpy.core.multiarray")?;
4949
let c_api = numpy.as_object().getattr(py, "_ARRAY_API")?;
5050
let api = unsafe {
51-
pyffi::PyCapsule_GetPointer(c_api.as_object().as_ptr(), null_mut())
51+
pyo3::ffi::PyCapsule_GetPointer(c_api.as_object().as_ptr(), null_mut())
5252
as *const *const c_void
5353
};
5454
Ok(Self {
@@ -375,10 +375,10 @@ impl_array_type!(
375375

376376
#[allow(non_snake_case)]
377377
pub unsafe fn PyArray_Check(np: &PyArrayModule, op: *mut PyObject) -> c_int {
378-
pyffi::PyObject_TypeCheck(op, np.get_type_object(ArrayType::PyArray_Type))
378+
pyo3::ffi::PyObject_TypeCheck(op, np.get_type_object(ArrayType::PyArray_Type))
379379
}
380380

381381
#[allow(non_snake_case)]
382382
pub unsafe fn PyArray_CheckExact(np: &PyArrayModule, op: *mut PyObject) -> c_int {
383-
(pyffi::Py_TYPE(op) == np.get_type_object(ArrayType::PyArray_Type)) as c_int
383+
(pyo3::ffi::Py_TYPE(op) == np.get_type_object(ArrayType::PyArray_Type)) as c_int
384384
}

src/npyffi/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
//! basic usage of Python C API, especially for the reference counting.
88
//!
99
//! - http://docs.python.jp/3/c-api/
10-
//! - http://dgrunwald.github.io/rust-cpython/doc/cpython/
10+
//! - http://dgrunwald.github.io/rust-pyo3/doc/pyo3/
1111
1212
pub mod array;
1313
pub mod objects;

src/npyffi/objects.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#![allow(non_camel_case_types, non_snake_case)]
55

66
use libc::FILE;
7-
use pyffi::*;
7+
use pyo3::ffi::*;
88
use std::option::Option;
99
use std::os::raw::*;
1010

src/npyffi/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#![allow(non_camel_case_types)]
22

3-
use pyffi::{Py_hash_t, Py_intptr_t, Py_uintptr_t};
3+
use pyo3::ffi::{Py_hash_t, Py_intptr_t, Py_uintptr_t};
44
use std::os::raw::*;
55

66
pub type npy_intp = Py_intptr_t;

src/npyffi/ufunc.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ use std::ops::Deref;
66
use std::os::raw::*;
77
use std::ptr::null_mut;
88

9-
use cpython::{ObjectProtocol, PyModule, PyResult, Python, PythonObject};
10-
use pyffi;
11-
use pyffi::{PyObject, PyTypeObject};
9+
use pyo3::ffi;
10+
use pyo3::ffi::{PyObject, PyTypeObject};
11+
use pyo3::{ObjectProtocol, PyModule, PyResult, Python};
1212

1313
use super::objects::*;
1414
use super::types::*;
@@ -45,7 +45,7 @@ impl PyUFuncModule {
4545
let numpy = py.import("numpy.core.umath")?;
4646
let c_api = numpy.as_object().getattr(py, "_UFUNC_API")?;
4747
let api = unsafe {
48-
pyffi::PyCapsule_GetPointer(c_api.as_object().as_ptr(), null_mut())
48+
pyo3::ffi::PyCapsule_GetPointer(c_api.as_object().as_ptr(), null_mut())
4949
as *const *const c_void
5050
};
5151
Ok(Self {

tests/array.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
extern crate cpython;
1+
extern crate pyo3;
22
extern crate ndarray;
33
extern crate numpy;
44

@@ -7,7 +7,7 @@ use numpy::*;
77

88
#[test]
99
fn new() {
10-
let gil = cpython::Python::acquire_gil();
10+
let gil = pyo3::Python::acquire_gil();
1111
let np = PyArrayModule::import(gil.python()).unwrap();
1212
let n = 3;
1313
let m = 5;
@@ -19,7 +19,7 @@ fn new() {
1919

2020
#[test]
2121
fn zeros() {
22-
let gil = cpython::Python::acquire_gil();
22+
let gil = pyo3::Python::acquire_gil();
2323
let np = PyArrayModule::import(gil.python()).unwrap();
2424
let n = 3;
2525
let m = 5;
@@ -36,7 +36,7 @@ fn zeros() {
3636

3737
#[test]
3838
fn arange() {
39-
let gil = cpython::Python::acquire_gil();
39+
let gil = pyo3::Python::acquire_gil();
4040
let np = PyArrayModule::import(gil.python()).unwrap();
4141
let arr = PyArray::arange::<f64>(gil.python(), &np, 0.0, 1.0, 0.1);
4242
println!("ndim = {:?}", arr.ndim());
@@ -46,7 +46,7 @@ fn arange() {
4646

4747
#[test]
4848
fn as_array() {
49-
let gil = cpython::Python::acquire_gil();
49+
let gil = pyo3::Python::acquire_gil();
5050
let np = PyArrayModule::import(gil.python()).unwrap();
5151
let arr = PyArray::zeros::<f64>(gil.python(), &np, &[3, 2, 4], NPY_CORDER);
5252
let a = arr.as_array::<f64>().unwrap();
@@ -60,15 +60,15 @@ fn as_array() {
6060
#[test]
6161
#[should_panic]
6262
fn as_array_panic() {
63-
let gil = cpython::Python::acquire_gil();
63+
let gil = pyo3::Python::acquire_gil();
6464
let np = PyArrayModule::import(gil.python()).unwrap();
6565
let arr = PyArray::zeros::<i32>(gil.python(), &np, &[3, 2, 4], NPY_CORDER);
6666
let _a = arr.as_array::<f32>().unwrap();
6767
}
6868

6969
#[test]
7070
fn into_pyarray_vec() {
71-
let gil = cpython::Python::acquire_gil();
71+
let gil = pyo3::Python::acquire_gil();
7272
let np = PyArrayModule::import(gil.python()).unwrap();
7373

7474
let a = vec![1, 2, 3];
@@ -80,7 +80,7 @@ fn into_pyarray_vec() {
8080

8181
#[test]
8282
fn into_pyarray_array() {
83-
let gil = cpython::Python::acquire_gil();
83+
let gil = pyo3::Python::acquire_gil();
8484
let np = PyArrayModule::import(gil.python()).unwrap();
8585

8686
let a = Array3::<f64>::zeros((3, 4, 2));
@@ -97,7 +97,7 @@ fn into_pyarray_array() {
9797

9898
#[test]
9999
fn iter_to_pyarray() {
100-
let gil = cpython::Python::acquire_gil();
100+
let gil = pyo3::Python::acquire_gil();
101101
let np = PyArrayModule::import(gil.python()).unwrap();
102102
let arr = (0..10).map(|x| x * x).to_pyarray(gil.python(), &np);
103103
println!("arr.shape = {:?}", arr.shape());

0 commit comments

Comments
 (0)