update tests
This commit is contained in:
parent
13ac12a568
commit
a95de027c1
|
@ -1,12 +1,10 @@
|
|||
language: python
|
||||
python:
|
||||
- "2.7"
|
||||
- "3.3"
|
||||
- "3.4"
|
||||
- "3.5"
|
||||
- "3.6"
|
||||
env:
|
||||
- RUST_VERSION=1.13.0
|
||||
- RUST_VERSION=1.15.1
|
||||
- RUST_VERSION=nightly
|
||||
sudo: false
|
||||
install:
|
||||
|
@ -22,4 +20,3 @@ install:
|
|||
- rustc -V
|
||||
script:
|
||||
- make test extensions
|
||||
|
||||
|
|
|
@ -617,7 +617,6 @@ mod test {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature="python3-sys")] // array.array doesn't implement the buffer protocol in python 2.7
|
||||
fn test_array_buffer() {
|
||||
let gil = Python::acquire_gil();
|
||||
let py = gil.python();
|
||||
|
|
|
@ -39,9 +39,9 @@ Defines a new exception type.
|
|||
# Example
|
||||
```
|
||||
#[macro_use]
|
||||
extern crate cpython;
|
||||
extern crate pyo3;
|
||||
|
||||
use cpython::{Python, PyDict};
|
||||
use pyo3::{Python, PyDict};
|
||||
|
||||
py_exception!(mymodule, CustomError);
|
||||
|
||||
|
|
|
@ -1,30 +1,15 @@
|
|||
rust-python3-sys
|
||||
====================
|
||||
rust python3 ffi
|
||||
================
|
||||
|
||||
[Rust](http://www.rust-lang.org/) FFI declarations for Python 3.
|
||||
Supports the PEP 384 stable ABI for Python 3.3 or higher.
|
||||
Supports the PEP 384 stable ABI for Python 3.4 or higher.
|
||||
|
||||
---
|
||||
|
||||
This [cargo -sys package](http://doc.crates.io/build-script.html#*-sys-packages) provides `python3` declarations.
|
||||
Licensed under the Python license (see `LICENSE`).
|
||||
|
||||
For a safe high-level API, see [rust-cpython](https://github.com/dgrunwald/rust-cpython).
|
||||
|
||||
# Usage
|
||||
|
||||
[`python3-sys` is available on crates.io](https://crates.io/crates/python3-sys) so you can use it like this (in your `Cargo.toml`):
|
||||
|
||||
```toml
|
||||
[dependencies.python3-sys]
|
||||
version = "*"
|
||||
```
|
||||
|
||||
In Rust, import the crate like this:
|
||||
|
||||
```rust
|
||||
extern crate python3_sys as py;
|
||||
```
|
||||
For a safe high-level API, see [rust-cpython](https://github.com/PyO3/PyO3).
|
||||
|
||||
Documentation for the python API is available on [https://docs.python.org/3/c-api/].
|
||||
|
||||
|
|
|
@ -78,9 +78,9 @@ macro_rules! py_method_def {
|
|||
///
|
||||
/// # Example
|
||||
/// ```
|
||||
/// #[macro_use] extern crate cpython;
|
||||
/// use cpython::{Python, PyResult, PyErr, PyDict};
|
||||
/// use cpython::{exc};
|
||||
/// #[macro_use] extern crate pyo3;
|
||||
/// use pyo3::{Python, PyResult, PyErr, PyDict};
|
||||
/// use pyo3::{exc};
|
||||
///
|
||||
/// fn multiply(py: Python, lhs: i32, rhs: i32) -> PyResult<i32> {
|
||||
/// match lhs.checked_mul(rhs) {
|
||||
|
|
18
src/lib.rs
18
src/lib.rs
|
@ -51,14 +51,14 @@
|
|||
//! The vast majority of operations in this library will return `PyResult<...>`.
|
||||
//! This is an alias for the type `Result<..., PyErr>`.
|
||||
//!
|
||||
//! A `PyErr` represents a Python exception. Errors within the rust-cpython library are
|
||||
//! A `PyErr` represents a Python exception. Errors within the PyO3 library are
|
||||
//! also exposed as Python exceptions.
|
||||
//!
|
||||
//! # Example
|
||||
//! ```
|
||||
//! extern crate cpython;
|
||||
//! extern crate pyo3;
|
||||
//!
|
||||
//! use cpython::{Python, PyDict, PyResult};
|
||||
//! use pyo3::{Python, PyDict, PyResult};
|
||||
//!
|
||||
//! fn main() {
|
||||
//! let gil = Python::acquire_gil();
|
||||
|
@ -204,10 +204,10 @@ pub mod _detail {
|
|||
///
|
||||
/// # Example
|
||||
/// ```
|
||||
/// #[macro_use] extern crate cpython;
|
||||
/// use cpython::{Python, PyResult, PyObject};
|
||||
/// #[macro_use] extern crate pyo3;
|
||||
/// use pyo3::{Python, PyResult, PyObject};
|
||||
///
|
||||
/// py_module_initializer!(hello, inithello, PyInit_hello, |py, m| {
|
||||
/// py_module_initializer!(hello, PyInit_hello, |py, m| {
|
||||
/// m.add(py, "__doc__", "Module documentation string")?;
|
||||
/// m.add(py, "run", py_fn!(py, run()))?;
|
||||
/// Ok(())
|
||||
|
@ -220,14 +220,14 @@ pub mod _detail {
|
|||
/// # fn main() {}
|
||||
/// ```
|
||||
///
|
||||
/// In your `Cargo.toml`, use the `extension-module` feature for the `cpython` dependency:
|
||||
/// In your `Cargo.toml`, use the `extension-module` feature for the `pyo3` dependency:
|
||||
/// ```cargo
|
||||
/// [dependencies.cpython]
|
||||
/// [dependencies.pyo3]
|
||||
/// version = "*"
|
||||
/// features = ["extension-module"]
|
||||
/// ```
|
||||
/// The full example project can be found at:
|
||||
/// https://github.com/dgrunwald/rust-cpython/tree/master/extensions/hello
|
||||
/// https://github.com/PyO3/setuptools-rust/tree/master/example/extensions
|
||||
///
|
||||
/// Rust will compile the code into a file named `libhello.so`, but we have to
|
||||
/// rename the file in order to use it with Python:
|
||||
|
|
|
@ -189,10 +189,10 @@ tuple_conversion!(9, (ref0, 0, A), (ref1, 1, B), (ref2, 2, C), (ref3, 3, D),
|
|||
///
|
||||
/// # Example
|
||||
/// ```
|
||||
/// let gil_guard = cpython::Python::acquire_gil();
|
||||
/// let py = gil_guard.python();
|
||||
/// let gil = pyo3::Python::acquire_gil();
|
||||
/// let py = gil.python();
|
||||
/// let os = py.import("os").unwrap();
|
||||
/// let pid = os.call(py, "get_pid", cpython::NoArgs, None);
|
||||
/// let pid = os.call(py, "get_pid", pyo3::NoArgs, None);
|
||||
/// ```
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
pub struct NoArgs;
|
||||
|
|
|
@ -33,8 +33,8 @@ in all function bodies.
|
|||
|
||||
# Example
|
||||
```
|
||||
#[macro_use] extern crate cpython;
|
||||
use cpython::{Python, PyResult, PyDict};
|
||||
#[macro_use] extern crate pyo3;
|
||||
use pyo3::{Python, PyResult, PyDict};
|
||||
|
||||
py_class!(class MyType |py| {
|
||||
data number: i32;
|
||||
|
@ -87,7 +87,7 @@ impl MyType {
|
|||
}
|
||||
```
|
||||
|
||||
* The generated type implements a number of traits from the `cpython` crate.
|
||||
* The generated type implements a number of traits from the `pyo3` crate.
|
||||
* The inherent `create_instance` method can create new Python objects
|
||||
given the values for the data fields.
|
||||
* Private accessors functions are created for the data fields.
|
||||
|
@ -182,9 +182,9 @@ as every cycle must contain at least one mutable reference.
|
|||
Example:
|
||||
|
||||
```
|
||||
#[macro_use] extern crate cpython;
|
||||
#[macro_use] extern crate pyo3;
|
||||
use std::{mem, cell};
|
||||
use cpython::{PyObject, PyDrop};
|
||||
use pyo3::{PyObject, PyDrop};
|
||||
|
||||
py_class!(class ClassWithGCSupport |py| {
|
||||
data obj: cell::RefCell<Option<PyObject>>;
|
||||
|
@ -235,9 +235,9 @@ Iterators can be defined using the Python special methods `__iter__` and `__next
|
|||
Example:
|
||||
|
||||
```
|
||||
#[macro_use] extern crate cpython;
|
||||
#[macro_use] extern crate pyo3;
|
||||
use std::cell::RefCell;
|
||||
use cpython::{PyObject, PyClone, PyResult};
|
||||
use pyo3::{PyObject, PyClone, PyResult};
|
||||
|
||||
py_class!(class MyIterator |py| {
|
||||
data iter: RefCell<Box<Iterator<Item=PyObject> + Send>>;
|
||||
|
|
|
@ -72,7 +72,6 @@ macro_rules! py_class_type_object_flags {
|
|||
};
|
||||
}
|
||||
|
||||
#[cfg(feature="python3-sys")]
|
||||
pub const TPFLAGS_DEFAULT : ::libc::c_ulong = ffi::Py_TPFLAGS_DEFAULT;
|
||||
|
||||
#[cfg(Py_3_5)]
|
||||
|
|
|
@ -78,7 +78,7 @@ pub fn prepare_freethreaded_python() {
|
|||
///
|
||||
/// # Example
|
||||
/// ```
|
||||
/// use cpython::Python;
|
||||
/// use pyo3::Python;
|
||||
///
|
||||
/// {
|
||||
/// let gil_guard = Python::acquire_gil();
|
||||
|
@ -123,7 +123,7 @@ impl GILGuard {
|
|||
/// # Example
|
||||
/// ```
|
||||
/// use std::cell::Cell;
|
||||
/// use cpython::{Python, GILProtected};
|
||||
/// use pyo3::{Python, GILProtected};
|
||||
///
|
||||
/// let data = GILProtected::new(Cell::new(0));
|
||||
///
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
#![allow(dead_code, unused_variables)]
|
||||
|
||||
#[macro_use] extern crate cpython;
|
||||
#[macro_use] extern crate pyo3;
|
||||
|
||||
use cpython::*;
|
||||
use pyo3::*;
|
||||
use std::{mem, isize, iter};
|
||||
use std::cell::{Cell, RefCell};
|
||||
use std::sync::Arc;
|
||||
use std::sync::atomic::{AtomicBool, Ordering};
|
||||
use cpython::_detail::ffi;
|
||||
use pyo3::ffi;
|
||||
|
||||
macro_rules! py_run {
|
||||
($py:expr, $val:ident, $code:expr) => {{
|
||||
|
@ -369,8 +369,8 @@ py_class!(class StringMethods |py| {
|
|||
Ok(format!("format({})", format_spec))
|
||||
}
|
||||
|
||||
def __unicode__(&self) -> PyResult<PyUnicode> {
|
||||
Ok(PyUnicode::new(py, "unicode"))
|
||||
def __unicode__(&self) -> PyResult<PyString> {
|
||||
Ok(PyString::new(py, "unicode"))
|
||||
}
|
||||
|
||||
def __bytes__(&self) -> PyResult<PyBytes> {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#[macro_use] extern crate cpython;
|
||||
#[macro_use] extern crate pyo3;
|
||||
|
||||
use cpython::{PyResult, Python, NoArgs, ObjectProtocol, PyDict};
|
||||
use pyo3::{PyResult, Python, NoArgs, ObjectProtocol, PyDict};
|
||||
use std::sync::atomic;
|
||||
use std::sync::atomic::Ordering::Relaxed;
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
#![allow(dead_code, unused_variables)]
|
||||
|
||||
#[macro_use] extern crate cpython;
|
||||
#[macro_use] extern crate pyo3;
|
||||
|
||||
use cpython::*;
|
||||
use pyo3::*;
|
||||
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in a new issue