Merge branch 'master' into abi3-merge-master

This commit is contained in:
Alex Gaynor 2020-10-12 18:03:14 -04:00
commit 9e34835b76
13 changed files with 67 additions and 48 deletions

View File

@ -45,7 +45,7 @@ jobs:
fail-fast: false # If one platform fails, allow the rest to keep testing.
matrix:
rust: [stable]
python-version: [3.5, 3.6, 3.7, 3.8, 3.9-dev, pypy3]
python-version: [3.5, 3.6, 3.7, 3.8, 3.9, pypy3]
platform: [
{ os: "macOS-latest", python-architecture: "x64", rust-target: "x86_64-apple-darwin" },
{ os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" },
@ -59,7 +59,7 @@ jobs:
include:
# Test minimal supported Rust version
- rust: 1.39.0
python-version: 3.8
python-version: 3.9
platform: { os: "ubuntu-latest", python-architecture: "x64", rust-target: "x86_64-unknown-linux-gnu" }
msrv: "MSRV"
@ -78,30 +78,29 @@ jobs:
toolchain: ${{ matrix.rust }}
target: ${{ matrix.platform.rust-target }}
profile: minimal
default: true
- if: matrix.platform.os == 'ubuntu-latest'
name: Prepare LD_LIBRARY_PATH (Ubuntu only)
run: echo ::set-env name=LD_LIBRARY_PATH::${pythonLocation}/lib
- run: rustup set default-host ${{ matrix.platform.rust-target }}
run: echo LD_LIBRARY_PATH=${pythonLocation}/lib >> $GITHUB_ENV
- name: Build without default features
run: cargo build --no-default-features --verbose
run: cargo build --no-default-features --verbose --target ${{ matrix.platform.rust-target }}
- name: Build with default features
run: cargo build --features "num-bigint num-complex" --verbose
run: cargo build --features "num-bigint num-complex" --verbose --target ${{ matrix.platform.rust-target }}
# Run tests (except on PyPy, because no embedding API).
- if: matrix.python-version != 'pypy3'
name: Test
run: cargo test --features "num-bigint num-complex"
run: cargo test --features "num-bigint num-complex" --target ${{ matrix.platform.rust-target }}
# Run tests again, but in abi3 mode
- if: matrix.python-version != 'pypy3'
name: Test
run: cargo test --no-default-features --features "abi3,macros"
name: Test (abi3)
run: cargo test --no-default-features --features "abi3,macros" --target ${{ matrix.platform.rust-target }}
- name: Test proc-macro code
run: cargo test --manifest-path=pyo3-derive-backend/Cargo.toml
run: cargo test --manifest-path=pyo3-derive-backend/Cargo.toml --target ${{ matrix.platform.rust-target }}
- name: Install python test dependencies
run: |

View File

@ -6,6 +6,10 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Fixed
- Fix support for Rust versions 1.39 to 1.44, broken by an incorrect internal update to paste 1.0 which was done in PyO3 0.12.2. [#1234](https://github.com/PyO3/pyo3/pull/1234)
## [0.12.2] - 2020-10-12
### Added
- Add support for building for CPython limited API. This required a few minor changes to runtime behaviour of of pyo3 `#[pyclass]` types. See the migration guide for full details. [#1152](https://github.com/PyO3/pyo3/pull/1152)
@ -16,13 +20,12 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [Unreleased]
### Added
- Add support for keyword-only arguments without default values in `#[pyfunction]`. [#1209](https://github.com/PyO3/pyo3/pull/1209)
- Add a wrapper for `PyErr_CheckSignals()` as `Python::check_signals()`. [#1214](https://github.com/PyO3/pyo3/pull/1214)
### Changed
- Fields of `PyMethodDef`, `PyGetterDef`, `PySetterDef`, and `PyClassAttributeDef` are now private. [#1169](https://github.com/PyO3/pyo3/pull/1169)
- Add `Python::check_signals()` as a safe a wrapper for `PyErr_CheckSignals()`. [#1214](https://github.com/PyO3/pyo3/pull/1214)
### Fixed
- Fix invalid document for protocol methods. [#1169](https://github.com/PyO3/pyo3/pull/1169)
- Hide docs of PyO3 private implementation details in `pyo3::class::methods`. [#1169](https://github.com/PyO3/pyo3/pull/1169)
- Fix unnecessary rebuild on PATH changes when the python interpreter is provided by PYO3_PYTHON. [#1231](https://github.com/PyO3/pyo3/pull/1231)
## [0.12.1] - 2020-09-16
### Fixed
@ -520,7 +523,8 @@ Yanked
### Added
- Initial release
[Unreleased]: https://github.com/pyo3/pyo3/compare/v0.12.1...HEAD
[Unreleased]: https://github.com/pyo3/pyo3/compare/v0.12.2...HEAD
[0.12.2]: https://github.com/pyo3/pyo3/compare/v0.12.1...v0.12.2
[0.12.1]: https://github.com/pyo3/pyo3/compare/v0.12.0...v0.12.1
[0.12.0]: https://github.com/pyo3/pyo3/compare/v0.11.1...v0.12.0
[0.11.1]: https://github.com/pyo3/pyo3/compare/v0.11.0...v0.11.1

View File

@ -1,6 +1,6 @@
[package]
name = "pyo3"
version = "0.12.1"
version = "0.12.2"
description = "Bindings to Python interpreter"
authors = ["PyO3 Project and Contributors <https://github.com/PyO3>"]
readme = "README.md"
@ -22,8 +22,8 @@ libc = "0.2.62"
parking_lot = "0.11.0"
num-bigint = { version = "0.3", optional = true }
num-complex = { version = "0.3", optional = true }
paste = { version = "1.0.1", optional = true }
pyo3cls = { path = "pyo3cls", version = "=0.12.1", optional = true }
paste = { version = "0.1.6", optional = true }
pyo3cls = { path = "pyo3cls", version = "=0.12.2", optional = true }
unindent = { version = "0.1.4", optional = true }
hashbrown = { version = "0.9", optional = true }

View File

@ -49,7 +49,7 @@ Here are a few things to note when you are writing PRs.
The PyO3 repo uses Github Actions. PRs are blocked from merging if CI is not successful.
Formatting, linting and tests are checked for all Rust and Python code. Tests run with all supported Python versions with the latest stable Rust compiler, as well as for Python 3.8 with the minimum supported Rust version.
Formatting, linting and tests are checked for all Rust and Python code. Tests run with all supported Python versions with the latest stable Rust compiler, as well as for Python 3.9 with the minimum supported Rust version.
### Minimum supported Rust version
@ -60,3 +60,13 @@ However, there will always be support for at least the last few Rust compiler ve
If your PR needs to bump the minimum supported Rust version, this is acceptable with the following conditions:
- Any changes which require a more recent version than what is [currently available on stable Red Hat Enterprise Linux](https://access.redhat.com/documentation/en-us/red_hat_developer_tools/1/) will be postponed. (This is to allow package managers to update support for newer `rustc` versions; RHEL was arbitrarily picked because their update policy is clear.)
- You might be asked to do extra work to tidy up other parts of the PyO3 codebase which can use the compiler version bump :)
## Benchmarking
PyO3 has two sets of benchmarks for evaluating some aspects of its performance. The benchmark suite is currently very small - please feel welcome to open PRs with new benchmarks if you're interested in helping to expand it!
First, there are Rust-based benchmarks located in the `benches` subdirectory. As long as you have a nightly rust compiler available on your system, you can run these benchmarks with:
cargo +nightly bench
Second, there is a Python-based benchmark contained in the `word-count` example. You can read more about it [here](examples/word-count#benchmark).

View File

@ -48,7 +48,7 @@ name = "string_sum"
crate-type = ["cdylib"]
[dependencies.pyo3]
version = "0.12.1"
version = "0.12.2"
features = ["extension-module"]
```
@ -99,7 +99,7 @@ use it to run Python code, add `pyo3` to your `Cargo.toml` like this:
```toml
[dependencies]
pyo3 = "0.12.1"
pyo3 = "0.12.2"
```
Example program displaying the value of `sys.version` and the current user name:

View File

@ -898,17 +898,20 @@ fn main() -> Result<()> {
// TODO: Find out how we can set -undefined dynamic_lookup here (if this is possible)
}
let env_vars = [
"LD_LIBRARY_PATH",
"PATH",
"PYTHON_SYS_EXECUTABLE",
"PYO3_PYTHON",
"LIB",
];
for var in env_vars.iter() {
for var in ["LIB", "LD_LIBRARY_PATH", "PYO3_PYTHON"].iter() {
println!("cargo:rerun-if-env-changed={}", var);
}
if env::var_os("PYO3_PYTHON").is_none() {
// When PYO3_PYTHON is not used, PYTHON_SYS_EXECUTABLE has the highest priority.
// Let's watch it.
println!("cargo:rerun-if-env-changed=PYTHON_SYS_EXECUTABLE");
if env::var_os("PYTHON_SYS_EXECUTABLE").is_none() {
// When PYTHON_SYS_EXECUTABLE is also not used, then we use PATH.
// Let's watch this, too.
println!("cargo:rerun-if-env-changed=PATH");
}
}
Ok(())
}

View File

@ -76,7 +76,7 @@ let err: PyErr = TypeError::py_err("error message");
After:
```
```rust
# use pyo3::{PyErr, PyResult, Python, type_object::PyTypeObject};
# use pyo3::exceptions::{PyBaseException, PyTypeError};
# Python::with_gil(|py| -> PyResult<()> {

View File

@ -1,6 +1,6 @@
[package]
name = "pyo3-derive-backend"
version = "0.12.1"
version = "0.12.2"
description = "Code generation for PyO3 package"
authors = ["PyO3 Project and Contributors <https://github.com/PyO3>"]
keywords = ["pyo3", "python", "cpython", "ffi"]

View File

@ -1,6 +1,6 @@
[package]
name = "pyo3cls"
version = "0.12.1"
version = "0.12.2"
description = "Proc macros for PyO3 package"
authors = ["PyO3 Project and Contributors <https://github.com/PyO3>"]
keywords = ["pyo3", "python", "cpython", "ffi"]
@ -16,4 +16,4 @@ proc-macro = true
[dependencies]
quote = "1"
syn = { version = "1", features = ["full", "extra-traits"] }
pyo3-derive-backend = { path = "../pyo3-derive-backend", version = "=0.12.1" }
pyo3-derive-backend = { path = "../pyo3-derive-backend", version = "=0.12.2" }

View File

@ -40,7 +40,7 @@ unsafe impl Sync for PyErr {}
/// Represents the result of a Python call.
pub type PyResult<T> = Result<T, PyErr>;
/// Marker type that indicates an error while downcasting
/// Error that indicates a failure to convert a PyAny to a more specific Python type.
#[derive(Debug)]
pub struct PyDowncastError<'a> {
from: &'a PyAny,

View File

@ -52,7 +52,7 @@
//! crate-type = ["cdylib"]
//!
//! [dependencies.pyo3]
//! version = "0.12.1"
//! version = "0.12.2"
//! features = ["extension-module"]
//! ```
//!
@ -109,7 +109,7 @@
//!
//! ```toml
//! [dependencies]
//! pyo3 = "0.12.1"
//! pyo3 = "0.12.2"
//! ```
//!
//! Example program displaying the value of `sys.version`:

View File

@ -72,15 +72,6 @@ macro_rules! pyobject_native_type_named (
unsafe { $crate::Py::from_borrowed_ptr(py, self.as_ptr()) }
}
}
impl<$($type_param,)*> From<&'_ $name> for $crate::Py<$name> {
#[inline]
fn from(other: &$name) -> Self {
use $crate::AsPyPointer;
use $crate::PyNativeType;
unsafe { $crate::Py::from_borrowed_ptr(other.py(), other.as_ptr()) }
}
}
};
);
@ -97,6 +88,18 @@ macro_rules! pyobject_native_type_core {
unsafe{&*(ob as *const $name as *const $crate::PyAny)}
}
}
// TODO: Rust>=1.40 allows this impl for rust-numpy.
// So we should move this to `named` or `convert` when we bump MSRV.
impl<$($type_param,)*> From<&'_ $name> for $crate::Py<$name> {
#[inline]
fn from(other: &$name) -> Self {
use $crate::AsPyPointer;
use $crate::PyNativeType;
unsafe { $crate::Py::from_borrowed_ptr(other.py(), other.as_ptr()) }
}
}
}
}

View File

@ -2,7 +2,6 @@
#[test]
fn test_compile_errors() {
let t = trybuild::TestCases::new();
t.compile_fail("tests/ui/invalid_frompy_derive.rs");
t.compile_fail("tests/ui/invalid_macro_args.rs");
t.compile_fail("tests/ui/invalid_need_module_arg_position.rs");
t.compile_fail("tests/ui/invalid_property_args.rs");
@ -23,6 +22,7 @@ fn test_compile_errors() {
#[rustversion::since(1.46)]
fn tests_rust_1_46(t: &trybuild::TestCases) {
t.compile_fail("tests/ui/invalid_frompy_derive.rs");
t.compile_fail("tests/ui/invalid_pymethod_receiver.rs");
t.compile_fail("tests/ui/invalid_result_conversion.rs");
t.compile_fail("tests/ui/missing_clone.rs");