Skip to content

Commit ca82681

Browse files
authored
ci: minor cleanups following 1.63 MSRV (#4239)
* ci: minor cleanups following 1.63 MSRV * correct `invalid_pymethods_duplicates` UI test * fix `nightly` feature
1 parent a983b2f commit ca82681

File tree

11 files changed

+31
-126
lines changed

11 files changed

+31
-126
lines changed

.github/workflows/build.yml

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ on:
1616
rust-target:
1717
required: true
1818
type: string
19-
extra-features:
20-
required: true
21-
type: string
2219

2320
jobs:
2421
build:
@@ -62,6 +59,10 @@ jobs:
6259
name: Ignore changed error messages when using trybuild
6360
run: echo "TRYBUILD=overwrite" >> "$GITHUB_ENV"
6461

62+
- if: inputs.rust == 'nightly'
63+
name: Prepare to test on nightly rust
64+
run: echo "MAYBE_NIGHTLY=nightly" >> "$GITHUB_ENV"
65+
6566
- name: Build docs
6667
run: nox -s docs
6768

@@ -88,26 +89,31 @@ jobs:
8889
8990
- name: Build (all additive features)
9091
if: ${{ !startsWith(inputs.python-version, 'graalpy') }}
91-
run: cargo build --lib --tests --no-default-features --features "full ${{ inputs.extra-features }}"
92+
run: cargo build --lib --tests --no-default-features --features "multiple-pymethods full $MAYBE_NIGHTLY"
9293

9394
- if: ${{ startsWith(inputs.python-version, 'pypy') }}
9495
name: Build PyPy (abi3-py37)
95-
run: cargo build --lib --tests --no-default-features --features "abi3-py37 full ${{ inputs.extra-features }}"
96+
run: cargo build --lib --tests --no-default-features --features "multiple-pymethods abi3-py37 full $MAYBE_NIGHTLY"
9697

9798
# Run tests (except on PyPy, because no embedding API).
9899
- if: ${{ !startsWith(inputs.python-version, 'pypy') && !startsWith(inputs.python-version, 'graalpy') }}
99100
name: Test
100-
run: cargo test --no-default-features --features "full ${{ inputs.extra-features }}"
101+
run: cargo test --no-default-features --features "full $MAYBE_NIGHTLY"
102+
103+
# Repeat, with multiple-pymethods feature enabled (it's not entirely additive)
104+
- if: ${{ !startsWith(inputs.python-version, 'pypy') && !startsWith(inputs.python-version, 'graalpy') }}
105+
name: Test
106+
run: cargo test --no-default-features --features "multiple-pymethods full $MAYBE_NIGHTLY"
101107

102108
# Run tests again, but in abi3 mode
103109
- if: ${{ !startsWith(inputs.python-version, 'pypy') && !startsWith(inputs.python-version, 'graalpy') }}
104110
name: Test (abi3)
105-
run: cargo test --no-default-features --features "abi3 full ${{ inputs.extra-features }}"
111+
run: cargo test --no-default-features --features "multiple-pymethods abi3 full $MAYBE_NIGHTLY"
106112

107113
# Run tests again, for abi3-py37 (the minimal Python version)
108114
- if: ${{ (!startsWith(inputs.python-version, 'pypy') && !startsWith(inputs.python-version, 'graalpy')) && (inputs.python-version != '3.7') }}
109115
name: Test (abi3-py37)
110-
run: cargo test --no-default-features --features "abi3-py37 full ${{ inputs.extra-features }}"
116+
run: cargo test --no-default-features --features "multiple-pymethods abi3-py37 full $MAYBE_NIGHTLY"
111117

112118
- name: Test proc-macro code
113119
run: cargo test --manifest-path=pyo3-macros-backend/Cargo.toml

.github/workflows/ci.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,11 @@ jobs:
149149
python-architecture: ${{ matrix.platform.python-architecture }}
150150
rust: ${{ matrix.rust }}
151151
rust-target: ${{ matrix.platform.rust-target }}
152-
extra-features: ${{ matrix.platform.extra-features }}
153152
secrets: inherit
154153
strategy:
155154
# If one platform fails, allow the rest to keep testing if `CI-no-fail-fast` label is present
156155
fail-fast: ${{ !contains(github.event.pull_request.labels.*.name, 'CI-no-fail-fast') }}
157156
matrix:
158-
extra-features: ["multiple-pymethods"]
159157
rust: [stable]
160158
python-version: ["3.12"]
161159
platform:
@@ -197,7 +195,6 @@ jobs:
197195
python-architecture: "x64",
198196
rust-target: "x86_64-unknown-linux-gnu",
199197
}
200-
extra-features: "nightly multiple-pymethods"
201198
build-full:
202199
if: ${{ contains(github.event.pull_request.labels.*.name, 'CI-build-full') || github.event_name != 'pull_request' }}
203200
name: python${{ matrix.python-version }}-${{ matrix.platform.python-architecture }} ${{ matrix.platform.os }} rust-${{ matrix.rust }}
@@ -209,13 +206,11 @@ jobs:
209206
python-architecture: ${{ matrix.platform.python-architecture }}
210207
rust: ${{ matrix.rust }}
211208
rust-target: ${{ matrix.platform.rust-target }}
212-
extra-features: ${{ matrix.platform.extra-features }}
213209
secrets: inherit
214210
strategy:
215211
# If one platform fails, allow the rest to keep testing if `CI-no-fail-fast` label is present
216212
fail-fast: ${{ !contains(github.event.pull_request.labels.*.name, 'CI-no-fail-fast') }}
217213
matrix:
218-
extra-features: ["multiple-pymethods"] # Because MSRV doesn't support this
219214
rust: [stable]
220215
python-version: [
221216
"3.7",
@@ -264,7 +259,6 @@ jobs:
264259
python-architecture: "x64",
265260
rust-target: "x86_64-unknown-linux-gnu",
266261
}
267-
extra-features: ""
268262

269263
# Test the `nightly` feature
270264
- rust: nightly
@@ -275,7 +269,6 @@ jobs:
275269
python-architecture: "x64",
276270
rust-target: "x86_64-unknown-linux-gnu",
277271
}
278-
extra-features: "nightly multiple-pymethods"
279272

280273
# Run rust beta to help catch toolchain regressions
281274
- rust: beta
@@ -286,7 +279,6 @@ jobs:
286279
python-architecture: "x64",
287280
rust-target: "x86_64-unknown-linux-gnu",
288281
}
289-
extra-features: "multiple-pymethods"
290282

291283
# Test 32-bit Windows only with the latest Python version
292284
- rust: stable
@@ -297,7 +289,6 @@ jobs:
297289
python-architecture: "x86",
298290
rust-target: "i686-pc-windows-msvc",
299291
}
300-
extra-features: "multiple-pymethods"
301292

302293
# test arm macos runner with the latest Python version
303294
# NB: if the full matrix switchess to arm, switch to x86_64 here
@@ -309,7 +300,6 @@ jobs:
309300
python-architecture: "arm64",
310301
rust-target: "aarch64-apple-darwin",
311302
}
312-
extra-features: "multiple-pymethods"
313303

314304
valgrind:
315305
if: ${{ contains(github.event.pull_request.labels.*.name, 'CI-build-full') || github.event_name != 'pull_request' }}

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ nightly = []
116116
# This is mostly intended for testing purposes - activating *all* of these isn't particularly useful.
117117
full = [
118118
"macros",
119-
# "multiple-pymethods", # TODO re-add this when MSRV is greater than 1.62
119+
# "multiple-pymethods", # Not supported by wasm
120120
"anyhow",
121121
"chrono",
122122
"chrono-tz",

guide/src/features.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,9 @@ These macros require a number of dependencies which may not be needed by users w
9595
9696
### `multiple-pymethods`
9797

98-
This feature enables a dependency on `inventory`, which enables each `#[pyclass]` to have more than one `#[pymethods]` block. This feature also requires a minimum Rust version of 1.62 due to limitations in the `inventory` crate.
98+
This feature enables each `#[pyclass]` to have more than one `#[pymethods]` block.
9999

100-
Most users should only need a single `#[pymethods]` per `#[pyclass]`. In addition, not all platforms (e.g. Wasm) are supported by `inventory`. For this reason this feature is not enabled by default, meaning fewer dependencies and faster compilation for the majority of users.
100+
Most users should only need a single `#[pymethods]` per `#[pyclass]`. In addition, not all platforms (e.g. Wasm) are supported by `inventory`, which is used in the implementation of the feature. For this reason this feature is not enabled by default, meaning fewer dependencies and faster compilation for the majority of users.
101101

102102
See [the `#[pyclass]` implementation details](class.md#implementation-details) for more information.
103103

noxfile.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ def check_feature_powerset(session: nox.Session):
663663
"default",
664664
"auto-initialize",
665665
"generate-import-lib",
666-
"multiple-pymethods", # TODO add this after MSRV 1.62
666+
"multiple-pymethods", # Because it's not supported on wasm
667667
}
668668

669669
features = cargo_toml["features"]
@@ -764,10 +764,9 @@ def _get_rust_default_target() -> str:
764764
@lru_cache()
765765
def _get_feature_sets() -> Tuple[Tuple[str, ...], ...]:
766766
"""Returns feature sets to use for clippy job"""
767-
rust_version = _get_rust_version()
768767
cargo_target = os.getenv("CARGO_BUILD_TARGET", "")
769-
if rust_version[:2] >= (1, 62) and "wasm32-wasi" not in cargo_target:
770-
# multiple-pymethods feature not supported before 1.62 or on WASI
768+
if "wasm32-wasi" not in cargo_target:
769+
# multiple-pymethods not supported on wasm
771770
return (
772771
("--no-default-features",),
773772
(

pyo3-ffi/src/methodobject.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,8 @@ impl std::fmt::Pointer for PyMethodDefPointer {
186186
}
187187
}
188188

189-
// TODO: This can be a const assert on Rust 1.57
190189
const _: () =
191-
[()][mem::size_of::<PyMethodDefPointer>() - mem::size_of::<Option<extern "C" fn()>>()];
190+
assert!(mem::size_of::<PyMethodDefPointer>() == mem::size_of::<Option<extern "C" fn()>>());
192191

193192
#[cfg(not(Py_3_9))]
194193
extern "C" {

src/conversions/chrono.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919
//! # Example: Convert a `datetime.datetime` to chrono's `DateTime<Utc>`
2020
//!
2121
//! ```rust
22-
//! # // `chrono::Duration` has been renamed to `chrono::TimeDelta` and its constructors changed
23-
//! # // TODO: upgrade to Chrono 0.4.35+ after upgrading our MSRV to 1.61+
24-
//! # #![allow(deprecated)]
2522
//! use chrono::{DateTime, Duration, TimeZone, Utc};
2623
//! use pyo3::{Python, ToPyObject};
2724
//!
@@ -43,10 +40,6 @@
4340
//! }
4441
//! ```
4542
46-
// `chrono::Duration` has been renamed to `chrono::TimeDelta` and its constructors changed
47-
// TODO: upgrade to Chrono 0.4.35+ after upgrading our MSRV to 1.61+
48-
#![allow(deprecated)]
49-
5043
use crate::exceptions::{PyTypeError, PyUserWarning, PyValueError};
5144
#[cfg(Py_LIMITED_API)]
5245
use crate::sync::GILOnceCell;

src/conversions/std/array.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ where
7575
}
7676

7777
// TODO use std::array::try_from_fn, if that stabilises:
78-
// (https://github.com/rust-lang/rust/pull/75644)
78+
// (https://github.com/rust-lang/rust/issues/89379)
7979
fn array_try_from_fn<E, F, T, const N: usize>(mut cb: F) -> Result<[T; N], E>
8080
where
8181
F: FnMut(usize) -> Result<T, E>,

src/marker.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ mod nightly {
281281

282282
// All the borrowing wrappers
283283
#[allow(deprecated)]
284+
#[cfg(feature = "gil-refs")]
284285
impl<T> !Ungil for crate::PyCell<T> {}
285286
impl<T> !Ungil for crate::PyRef<'_, T> {}
286287
impl<T> !Ungil for crate::PyRefMut<'_, T> {}

tests/ui/invalid_pymethods_duplicates.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
use pyo3::prelude::*;
55

6+
#[pyclass]
67
struct TwoNew {}
78

89
#[pymethods]
@@ -18,6 +19,7 @@ impl TwoNew {
1819
}
1920
}
2021

22+
#[pyclass]
2123
struct DuplicateMethod {}
2224

2325
#[pymethods]
Lines changed: 6 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,18 @@
11
error[E0119]: conflicting implementations of trait `pyo3::impl_::pyclass::PyClassNewTextSignature<TwoNew>` for type `pyo3::impl_::pyclass::PyClassImplCollector<TwoNew>`
2-
--> tests/ui/invalid_pymethods_duplicates.rs:8:1
2+
--> tests/ui/invalid_pymethods_duplicates.rs:9:1
33
|
4-
8 | #[pymethods]
4+
9 | #[pymethods]
55
| ^^^^^^^^^^^^
66
| |
77
| first implementation here
88
| conflicting implementation for `pyo3::impl_::pyclass::PyClassImplCollector<TwoNew>`
99
|
1010
= note: this error originates in the attribute macro `pymethods` (in Nightly builds, run with -Z macro-backtrace for more info)
1111

12-
error[E0277]: the trait bound `TwoNew: PyTypeInfo` is not satisfied
13-
--> tests/ui/invalid_pymethods_duplicates.rs:9:6
14-
|
15-
9 | impl TwoNew {
16-
| ^^^^^^ the trait `PyTypeInfo` is not implemented for `TwoNew`
17-
|
18-
= help: the following other types implement trait `PyTypeInfo`:
19-
CancelledError
20-
IncompleteReadError
21-
InvalidStateError
22-
LimitOverrunError
23-
PanicException
24-
PyAny
25-
PyArithmeticError
26-
PyAssertionError
27-
and $N others
28-
2912
error[E0592]: duplicate definitions with name `__pymethod___new____`
30-
--> tests/ui/invalid_pymethods_duplicates.rs:8:1
13+
--> tests/ui/invalid_pymethods_duplicates.rs:9:1
3114
|
32-
8 | #[pymethods]
15+
9 | #[pymethods]
3316
| ^^^^^^^^^^^^
3417
| |
3518
| duplicate definitions for `__pymethod___new____`
@@ -38,80 +21,12 @@ error[E0592]: duplicate definitions with name `__pymethod___new____`
3821
= note: this error originates in the attribute macro `pymethods` (in Nightly builds, run with -Z macro-backtrace for more info)
3922

4023
error[E0592]: duplicate definitions with name `__pymethod_func__`
41-
--> tests/ui/invalid_pymethods_duplicates.rs:23:1
24+
--> tests/ui/invalid_pymethods_duplicates.rs:25:1
4225
|
43-
23 | #[pymethods]
26+
25 | #[pymethods]
4427
| ^^^^^^^^^^^^
4528
| |
4629
| duplicate definitions for `__pymethod_func__`
4730
| other definition for `__pymethod_func__`
4831
|
4932
= note: this error originates in the attribute macro `pymethods` (in Nightly builds, run with -Z macro-backtrace for more info)
50-
51-
error[E0277]: the trait bound `TwoNew: PyClass` is not satisfied
52-
--> tests/ui/invalid_pymethods_duplicates.rs:8:1
53-
|
54-
8 | #[pymethods]
55-
| ^^^^^^^^^^^^ the trait `PyClass` is not implemented for `TwoNew`
56-
|
57-
= help: the trait `PyClass` is implemented for `pyo3::coroutine::Coroutine`
58-
note: required by a bound in `PyClassInitializer`
59-
--> src/pyclass_init.rs
60-
|
61-
| pub struct PyClassInitializer<T: PyClass>(PyClassInitializerImpl<T>);
62-
| ^^^^^^^ required by this bound in `PyClassInitializer`
63-
= note: this error originates in the attribute macro `pymethods` (in Nightly builds, run with -Z macro-backtrace for more info)
64-
65-
error[E0599]: no method named `convert` found for struct `TwoNew` in the current scope
66-
--> tests/ui/invalid_pymethods_duplicates.rs:8:1
67-
|
68-
6 | struct TwoNew {}
69-
| ------------- method `convert` not found for this struct
70-
7 |
71-
8 | #[pymethods]
72-
| ^^^^^^^^^^^^ method not found in `TwoNew`
73-
|
74-
= help: items from traits can only be used if the trait is implemented and in scope
75-
= note: the following trait defines an item `convert`, perhaps you need to implement it:
76-
candidate #1: `IntoPyCallbackOutput`
77-
= note: this error originates in the attribute macro `pymethods` (in Nightly builds, run with -Z macro-backtrace for more info)
78-
79-
error[E0277]: the trait bound `DuplicateMethod: PyClass` is not satisfied
80-
--> tests/ui/invalid_pymethods_duplicates.rs:26:15
81-
|
82-
26 | fn func_a(&self) {}
83-
| ^ the trait `PyClass` is not implemented for `DuplicateMethod`
84-
|
85-
= help: the trait `PyClass` is implemented for `pyo3::coroutine::Coroutine`
86-
note: required by a bound in `extract_pyclass_ref`
87-
--> src/impl_/extract_argument.rs
88-
|
89-
| pub fn extract_pyclass_ref<'a, 'py: 'a, T: PyClass>(
90-
| ^^^^^^^ required by this bound in `extract_pyclass_ref`
91-
92-
error[E0277]: the trait bound `DuplicateMethod: PyClass` is not satisfied
93-
--> tests/ui/invalid_pymethods_duplicates.rs:23:1
94-
|
95-
23 | #[pymethods]
96-
| ^^^^^^^^^^^^ the trait `PyClass` is not implemented for `DuplicateMethod`
97-
|
98-
= help: the trait `PyClass` is implemented for `pyo3::coroutine::Coroutine`
99-
note: required by a bound in `PyRef`
100-
--> src/pycell.rs
101-
|
102-
| pub struct PyRef<'p, T: PyClass> {
103-
| ^^^^^^^ required by this bound in `PyRef`
104-
= note: this error originates in the attribute macro `pymethods` (in Nightly builds, run with -Z macro-backtrace for more info)
105-
106-
error[E0277]: the trait bound `DuplicateMethod: PyClass` is not satisfied
107-
--> tests/ui/invalid_pymethods_duplicates.rs:29:15
108-
|
109-
29 | fn func_b(&self) {}
110-
| ^ the trait `PyClass` is not implemented for `DuplicateMethod`
111-
|
112-
= help: the trait `PyClass` is implemented for `pyo3::coroutine::Coroutine`
113-
note: required by a bound in `extract_pyclass_ref`
114-
--> src/impl_/extract_argument.rs
115-
|
116-
| pub fn extract_pyclass_ref<'a, 'py: 'a, T: PyClass>(
117-
| ^^^^^^^ required by this bound in `extract_pyclass_ref`

0 commit comments

Comments
 (0)