More nightly fixes
This commit is contained in:
parent
b12b65cfae
commit
991a8b94d2
|
@ -15,7 +15,7 @@ A comparison with rust-cpython can be found [in the guide](https://pyo3.rs/maste
|
|||
|
||||
## Usage
|
||||
|
||||
Pyo3 supports python 2.7 as well as python 3.5 and up. The minimum required rust version is 1.29.0-nightly 2018-07-16.
|
||||
Pyo3 supports python 2.7 as well as python 3.5 and up. The minimum required rust version is 1.30.0-nightly 2018-08-18.
|
||||
|
||||
You can either write a native python module in rust or use python from a rust binary.
|
||||
|
||||
|
@ -35,14 +35,14 @@ name = "rust_py"
|
|||
crate-type = ["cdylib"]
|
||||
|
||||
[dependencies.pyo3]
|
||||
version = "0.3"
|
||||
version = "0.4"
|
||||
features = ["extension-module"]
|
||||
```
|
||||
|
||||
**`src/lib.rs`**
|
||||
|
||||
```rust
|
||||
#![feature(use_extern_macros, specialization)]
|
||||
#![feature(specialization)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate pyo3;
|
||||
|
@ -90,7 +90,7 @@ pyo3 = "0.3"
|
|||
Example program displaying the value of `sys.version`:
|
||||
|
||||
```rust
|
||||
#![feature(use_extern_macros, specialization)]
|
||||
#![feature(specialization)]
|
||||
|
||||
extern crate pyo3;
|
||||
|
||||
|
|
6
build.rs
6
build.rs
|
@ -10,9 +10,9 @@ use std::process::Stdio;
|
|||
use version_check::{is_min_date, is_min_version, supports_features};
|
||||
|
||||
// Specifies the minimum nightly version needed to compile pyo3.
|
||||
// This requirement is due to https://github.com/rust-lang/rust/pull/52081
|
||||
const MIN_DATE: &'static str = "2018-07-16";
|
||||
const MIN_VERSION: &'static str = "1.29.0-nightly";
|
||||
// This requirements is due to the stabilization of use_extern_macros
|
||||
const MIN_DATE: &'static str = "2018-08-18";
|
||||
const MIN_VERSION: &'static str = "1.30.0-nightly";
|
||||
|
||||
#[derive(Debug)]
|
||||
struct PythonVersion {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Source adopted from
|
||||
// https://github.com/tildeio/helix-website/blob/master/crates/word_count/src/lib.rs
|
||||
#![feature(use_extern_macros, specialization)]
|
||||
#![feature(specialization)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate pyo3;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
To define python custom class, rust struct needs to be annotated with `#[pyclass]` attribute.
|
||||
|
||||
```rust
|
||||
# #![feature(use_extern_macros, specialization)]
|
||||
# #![feature(specialization)]
|
||||
# extern crate pyo3;
|
||||
# use pyo3::prelude::*;
|
||||
|
||||
|
@ -45,7 +45,7 @@ To declare a constructor, you need to define a class method and annotate it with
|
|||
attribute. Only the python `__new__` method can be specified, `__init__` is not available.
|
||||
|
||||
```rust
|
||||
# #![feature(use_extern_macros, specialization)]
|
||||
# #![feature(specialization)]
|
||||
#
|
||||
# extern crate pyo3;
|
||||
# use pyo3::prelude::*;
|
||||
|
@ -92,7 +92,7 @@ By default `PyObject` is used as default base class. To override default base cl
|
|||
with value of custom class struct. Subclass must call parent's `__new__` method.
|
||||
|
||||
```rust
|
||||
# #![feature(use_extern_macros, specialization)]
|
||||
# #![feature(specialization)]
|
||||
# extern crate pyo3;
|
||||
# use pyo3::prelude::*;
|
||||
#
|
||||
|
@ -145,7 +145,7 @@ Descriptor methods can be defined in
|
|||
attributes. i.e.
|
||||
|
||||
```rust
|
||||
# #![feature(use_extern_macros, specialization)]
|
||||
# #![feature(specialization)]
|
||||
# extern crate pyo3;
|
||||
# use pyo3::prelude::*;
|
||||
# #[pyclass]
|
||||
|
@ -172,7 +172,7 @@ Descriptor name becomes function name with prefix removed. This is useful in cas
|
|||
rust's special keywords like `type`.
|
||||
|
||||
```rust
|
||||
# #![feature(use_extern_macros, specialization)]
|
||||
# #![feature(specialization)]
|
||||
# extern crate pyo3;
|
||||
# use pyo3::prelude::*;
|
||||
# #[pyclass]
|
||||
|
@ -203,7 +203,7 @@ Also both `#[getter]` and `#[setter]` attributes accepts one parameter.
|
|||
If parameter is specified, it is used and property name. i.e.
|
||||
|
||||
```rust
|
||||
# #![feature(use_extern_macros, specialization)]
|
||||
# #![feature(specialization)]
|
||||
# extern crate pyo3;
|
||||
# use pyo3::prelude::*;
|
||||
# #[pyclass]
|
||||
|
@ -233,7 +233,7 @@ In this case property `number` is defined. And it is available from python code
|
|||
For simple cases you can also define getters and setters in your Rust struct field definition, for example:
|
||||
|
||||
```rust
|
||||
# #![feature(use_extern_macros, specialization)]
|
||||
# #![feature(specialization)]
|
||||
# extern crate pyo3;
|
||||
# use pyo3::prelude::*;
|
||||
#[pyclass]
|
||||
|
@ -253,7 +253,7 @@ wrappers for all functions in this block with some variations, like descriptors,
|
|||
class method static methods, etc.
|
||||
|
||||
```rust
|
||||
# #![feature(use_extern_macros, specialization)]
|
||||
# #![feature(specialization)]
|
||||
# extern crate pyo3;
|
||||
# use pyo3::prelude::*;
|
||||
# #[pyclass]
|
||||
|
@ -283,7 +283,7 @@ The return type must be `PyResult<T>` for some `T` that implements `IntoPyObject
|
|||
get injected by method wrapper. i.e
|
||||
|
||||
```rust
|
||||
# #![feature(use_extern_macros, specialization)]
|
||||
# #![feature(specialization)]
|
||||
# extern crate pyo3;
|
||||
# use pyo3::prelude::*;
|
||||
# #[pyclass]
|
||||
|
@ -309,7 +309,7 @@ To specify class method for custom class, method needs to be annotated
|
|||
with`#[classmethod]` attribute.
|
||||
|
||||
```rust
|
||||
# #![feature(use_extern_macros, specialization)]
|
||||
# #![feature(specialization)]
|
||||
# extern crate pyo3;
|
||||
# use pyo3::prelude::*;
|
||||
# #[pyclass]
|
||||
|
@ -343,7 +343,7 @@ with `#[staticmethod]` attribute. The return type must be `PyResult<T>`
|
|||
for some `T` that implements `IntoPyObject`.
|
||||
|
||||
```rust
|
||||
# #![feature(use_extern_macros, specialization)]
|
||||
# #![feature(specialization)]
|
||||
# extern crate pyo3;
|
||||
# use pyo3::prelude::*;
|
||||
# #[pyclass]
|
||||
|
@ -368,7 +368,7 @@ To specify custom `__call__` method for custom class, call method needs to be an
|
|||
with `#[call]` attribute. Arguments of the method are specified same as for instance method.
|
||||
|
||||
```rust
|
||||
# #![feature(use_extern_macros, specialization)]
|
||||
# #![feature(specialization)]
|
||||
# extern crate pyo3;
|
||||
# use pyo3::prelude::*;
|
||||
# #[pyclass]
|
||||
|
@ -413,7 +413,7 @@ Each parameter could one of following type:
|
|||
|
||||
Example:
|
||||
```rust
|
||||
# #![feature(use_extern_macros, specialization)]
|
||||
# #![feature(specialization)]
|
||||
# extern crate pyo3;
|
||||
# use pyo3::prelude::*;
|
||||
#
|
||||
|
@ -517,7 +517,7 @@ These correspond to the slots `tp_traverse` and `tp_clear` in the Python C API.
|
|||
as every cycle must contain at least one mutable reference.
|
||||
Example:
|
||||
```rust
|
||||
#![feature(use_extern_macros, specialization)]
|
||||
#![feature(specialization)]
|
||||
extern crate pyo3;
|
||||
|
||||
use pyo3::prelude::*;
|
||||
|
@ -566,7 +566,7 @@ It includes two methods `__iter__` and `__next__`:
|
|||
Example:
|
||||
|
||||
```rust
|
||||
#![feature(use_extern_macros, specialization)]
|
||||
#![feature(specialization)]
|
||||
extern crate pyo3;
|
||||
|
||||
use pyo3::prelude::*;
|
||||
|
|
|
@ -131,7 +131,7 @@ trait can be implemented. In that case actual exception arguments creation get d
|
|||
until `Python` object is available.
|
||||
|
||||
```rust,ignore
|
||||
#![feature(use_extern_macros, specialization)]
|
||||
#![feature(specialization)]
|
||||
extern crate pyo3;
|
||||
|
||||
use std::net::TcpListener;
|
||||
|
|
|
@ -31,7 +31,7 @@ features = ["extension-module"]
|
|||
**`src/lib.rs`**
|
||||
|
||||
```rust
|
||||
#![feature(use_extern_macros, specialization)]
|
||||
#![feature(specialization)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate pyo3;
|
||||
|
@ -79,7 +79,7 @@ pyo3 = "0.3"
|
|||
Example program displaying the value of `sys.version`:
|
||||
|
||||
```rust
|
||||
#![feature(use_extern_macros, specialization)]
|
||||
#![feature(specialization)]
|
||||
|
||||
extern crate pyo3;
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ py_class!(class MyClass |py| {
|
|||
**pyo3**
|
||||
|
||||
```rust
|
||||
#![feature(use_extern_macros, specialization)]
|
||||
#![feature(specialization)]
|
||||
|
||||
extern crate pyo3;
|
||||
|
||||
|
|
|
@ -201,7 +201,7 @@ fn impl_wrap_init(cls: &syn::Type, name: &syn::Ident, spec: &FnSpec) -> TokenStr
|
|||
unsafe extern "C" fn __wrap(
|
||||
_slf: *mut ::pyo3::ffi::PyObject,
|
||||
_args: *mut ::pyo3::ffi::PyObject,
|
||||
_kwargs: *mut ::pyo3::ffi::PyObject) -> ::pyo3::c_int
|
||||
_kwargs: *mut ::pyo3::ffi::PyObject) -> ::pyo3::libc::c_int
|
||||
{
|
||||
const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#name),"()");
|
||||
let _pool = ::pyo3::GILPool::new();
|
||||
|
@ -307,7 +307,7 @@ pub fn impl_wrap_static(cls: &syn::Type, name: &syn::Ident, spec: &FnSpec) -> To
|
|||
pub(crate) fn impl_wrap_getter(cls: &syn::Type, name: &syn::Ident) -> TokenStream {
|
||||
quote! {
|
||||
unsafe extern "C" fn __wrap(
|
||||
_slf: *mut ::pyo3::ffi::PyObject, _: *mut ::pyo3::c_void) -> *mut ::pyo3::ffi::PyObject
|
||||
_slf: *mut ::pyo3::ffi::PyObject, _: *mut std::os::raw::c_void) -> *mut ::pyo3::ffi::PyObject
|
||||
{
|
||||
const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#name),"()");
|
||||
|
||||
|
@ -339,7 +339,7 @@ pub(crate) fn impl_wrap_setter(cls: &syn::Type, name: &syn::Ident, spec: &FnSpec
|
|||
#[allow(unused_mut)]
|
||||
unsafe extern "C" fn __wrap(
|
||||
_slf: *mut ::pyo3::ffi::PyObject,
|
||||
_value: *mut ::pyo3::ffi::PyObject, _: *mut ::pyo3::c_void) -> ::pyo3::c_int
|
||||
_value: *mut ::pyo3::ffi::PyObject, _: *mut std::os::raw::c_void) -> ::pyo3::libc::c_int
|
||||
{
|
||||
const _LOCATION: &'static str = concat!(stringify!(#cls),".",stringify!(#name),"()");
|
||||
let _pool = ::pyo3::GILPool::new();
|
||||
|
|
|
@ -43,12 +43,10 @@ extern "C" {
|
|||
value: *const c_char,
|
||||
) -> c_int;
|
||||
|
||||
#[cfg(
|
||||
all(
|
||||
target_pointer_width = "64",
|
||||
not(py_sys_config = "Py_TRACE_REFS")
|
||||
)
|
||||
)]
|
||||
#[cfg(all(
|
||||
target_pointer_width = "64",
|
||||
not(py_sys_config = "Py_TRACE_REFS")
|
||||
))]
|
||||
fn Py_InitModule4_64(
|
||||
name: *const c_char,
|
||||
methods: *mut PyMethodDef,
|
||||
|
@ -66,12 +64,10 @@ extern "C" {
|
|||
apiver: c_int,
|
||||
) -> *mut PyObject;
|
||||
|
||||
#[cfg(
|
||||
all(
|
||||
not(target_pointer_width = "64"),
|
||||
not(py_sys_config = "Py_TRACE_REFS")
|
||||
)
|
||||
)]
|
||||
#[cfg(all(
|
||||
not(target_pointer_width = "64"),
|
||||
not(py_sys_config = "Py_TRACE_REFS")
|
||||
))]
|
||||
pub fn Py_InitModule4(
|
||||
name: *const c_char,
|
||||
methods: *mut PyMethodDef,
|
||||
|
@ -80,12 +76,10 @@ extern "C" {
|
|||
apiver: c_int,
|
||||
) -> *mut PyObject;
|
||||
|
||||
#[cfg(
|
||||
all(
|
||||
not(target_pointer_width = "64"),
|
||||
py_sys_config = "Py_TRACE_REFS"
|
||||
)
|
||||
)]
|
||||
#[cfg(all(
|
||||
not(target_pointer_width = "64"),
|
||||
py_sys_config = "Py_TRACE_REFS"
|
||||
))]
|
||||
fn Py_InitModule4TraceRefs(
|
||||
name: *const c_char,
|
||||
methods: *mut PyMethodDef,
|
||||
|
@ -97,12 +91,10 @@ extern "C" {
|
|||
|
||||
pub const PYTHON_API_VERSION: c_int = 1013;
|
||||
|
||||
#[cfg(
|
||||
all(
|
||||
target_pointer_width = "64",
|
||||
not(py_sys_config = "Py_TRACE_REFS")
|
||||
)
|
||||
)]
|
||||
#[cfg(all(
|
||||
target_pointer_width = "64",
|
||||
not(py_sys_config = "Py_TRACE_REFS")
|
||||
))]
|
||||
#[inline(always)]
|
||||
pub unsafe fn Py_InitModule4(
|
||||
name: *const c_char,
|
||||
|
@ -126,12 +118,10 @@ pub unsafe fn Py_InitModule4(
|
|||
Py_InitModule4TraceRefs_64(name, methods, doc, _self, apiver)
|
||||
}
|
||||
|
||||
#[cfg(
|
||||
all(
|
||||
not(target_pointer_width = "64"),
|
||||
py_sys_config = "Py_TRACE_REFS"
|
||||
)
|
||||
)]
|
||||
#[cfg(all(
|
||||
not(target_pointer_width = "64"),
|
||||
py_sys_config = "Py_TRACE_REFS"
|
||||
))]
|
||||
#[inline(always)]
|
||||
pub unsafe fn Py_InitModule4(
|
||||
name: *const c_char,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(specialization, use_extern_macros)]
|
||||
#![feature(specialization)]
|
||||
|
||||
//! Rust bindings to the Python interpreter.
|
||||
//!
|
||||
|
@ -29,7 +29,7 @@
|
|||
//! # Example
|
||||
//!
|
||||
//! ```rust
|
||||
//! #![feature(use_extern_macros, specialization)]
|
||||
//! #![feature(specialization)]
|
||||
//!
|
||||
//! extern crate pyo3;
|
||||
//!
|
||||
|
@ -68,7 +68,7 @@
|
|||
//! # Example
|
||||
//!
|
||||
//! ```rust
|
||||
//! #![feature(use_extern_macros, specialization)]
|
||||
//! #![feature(specialization)]
|
||||
//!
|
||||
//! extern crate pyo3;
|
||||
//! use pyo3::prelude::*;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(use_extern_macros, specialization)]
|
||||
#![feature(specialization)]
|
||||
|
||||
extern crate pyo3;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(use_extern_macros, specialization)]
|
||||
#![feature(specialization)]
|
||||
|
||||
extern crate pyo3;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(use_extern_macros, specialization)]
|
||||
#![feature(specialization)]
|
||||
|
||||
extern crate pyo3;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(use_extern_macros, specialization)]
|
||||
#![feature(specialization)]
|
||||
|
||||
extern crate pyo3;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(use_extern_macros, specialization)]
|
||||
#![feature(specialization)]
|
||||
|
||||
extern crate pyo3;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(use_extern_macros, specialization)]
|
||||
#![feature(specialization)]
|
||||
|
||||
extern crate pyo3;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(use_extern_macros, specialization)]
|
||||
#![feature(specialization)]
|
||||
|
||||
extern crate pyo3;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(use_extern_macros, specialization)]
|
||||
#![feature(specialization)]
|
||||
|
||||
extern crate pyo3;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(use_extern_macros, specialization)]
|
||||
#![feature(specialization)]
|
||||
|
||||
extern crate pyo3;
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(use_extern_macros, specialization)]
|
||||
#![feature(specialization)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate pyo3;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#![feature(use_extern_macros, specialization)]
|
||||
#![feature(specialization)]
|
||||
|
||||
extern crate pyo3;
|
||||
|
||||
|
|
Loading…
Reference in New Issue