Skip to content

Commit 3332f31

Browse files
bors[bot]adamreicholddavidhewitt
authored
Merge #3208
3208: bump msrv to 1.56 r=davidhewitt a=davidhewitt The MSRV changes from #3204, plus a commit which should hopefully make CI pass. With luck this is mergeable and resolves CI pain while we decide what to do about the Python version. Co-authored-by: Adam Reichold <adam.reichold@t-online.de> Co-authored-by: David Hewitt <1939362+davidhewitt@users.noreply.github.com>
2 parents 6b85130 + 5bc3e6f commit 3332f31

29 files changed

+172
-151
lines changed

.cargo/config

-5
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,6 @@ xtask = "run --package xtask --"
33

44
[target.'cfg(feature = "cargo-clippy")']
55
rustflags = [
6-
# TODO: remove these allows once msrv increased from 1.48
7-
"-Aclippy::iter_kv_map",
8-
"-Aclippy::needless_borrow",
9-
"-Aclippy::uninlined_format_args",
106
# Lints to enforce in CI
117
"-Dclippy::checked_conversions",
128
"-Dclippy::dbg_macro",
@@ -15,7 +11,6 @@ rustflags = [
1511
"-Dclippy::filter_map_next",
1612
"-Dclippy::flat_map_option",
1713
"-Dclippy::let_unit_value",
18-
"-Dclippy::manual_assert",
1914
"-Dclippy::manual_ok_or",
2015
"-Dclippy::todo",
2116
"-Dclippy::unnecessary_wraps",

.github/workflows/build.yml

-4
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,3 @@ jobs:
201201
# TODO: this is a hack to workaround compile_error! warnings about auto-initialize on PyPy
202202
# Once cargo's `resolver = "2"` is stable (~ MSRV Rust 1.52), remove this.
203203
PYO3_CI: 1
204-
# This is a hack to make CARGO_PRIMARY_PACKAGE always set even for the
205-
# msrv job. MSRV is currently 1.48, but CARGO_PRIMARY_PACKAGE only came in
206-
# 1.49.
207-
CARGO_PRIMARY_PACKAGE: 1

.github/workflows/ci.yml

+28-14
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,32 @@ jobs:
3434
- name: Check rust formatting (rustfmt)
3535
run: nox -s fmt-rust
3636

37+
check-msrv:
38+
needs: [fmt]
39+
runs-on: ubuntu-latest
40+
if: github.ref != 'refs/heads/main'
41+
steps:
42+
- uses: actions/checkout@v3
43+
- uses: dtolnay/rust-toolchain@master
44+
with:
45+
toolchain: 1.56.0
46+
targets: x86_64-unknown-linux-gnu
47+
components: clippy,rust-src
48+
- uses: actions/setup-python@v4
49+
with:
50+
architecture: "x64"
51+
- uses: Swatinem/rust-cache@v2
52+
with:
53+
key: check-msrv-1.56.0
54+
continue-on-error: true
55+
- run: python -m pip install --upgrade pip && pip install nox
56+
- name: Prepare minimal package versions
57+
run: nox -s set-minimal-package-versions
58+
- run: nox -s check-all
59+
60+
env:
61+
CARGO_BUILD_TARGET: x86_64-unknown-linux-gnu
62+
3763
clippy:
3864
needs: [fmt]
3965
runs-on: ${{ matrix.platform.os }}
@@ -80,16 +106,6 @@ jobs:
80106
rust-target: "i686-pc-windows-msvc",
81107
},
82108
]
83-
include:
84-
- rust: 1.48.0
85-
python-version: "3.11"
86-
platform:
87-
{
88-
os: "ubuntu-latest",
89-
python-architecture: "x64",
90-
rust-target: "x86_64-unknown-linux-gnu",
91-
}
92-
msrv: "MSRV"
93109
name: clippy/${{ matrix.platform.rust-target }}/${{ matrix.rust }}
94110
steps:
95111
- uses: actions/checkout@v3
@@ -106,9 +122,6 @@ jobs:
106122
key: clippy-${{ matrix.platform.rust-target }}-${{ matrix.platform.os }}-${{ matrix.rust }}
107123
continue-on-error: true
108124
- run: python -m pip install --upgrade pip && pip install nox
109-
- if: matrix.msrv == 'MSRV'
110-
name: Prepare minimal package versions (MSRV only)
111-
run: nox -s set-minimal-package-versions
112125
- run: nox -s clippy-all
113126
env:
114127
CARGO_BUILD_TARGET: ${{ matrix.platform.rust-target }}
@@ -207,7 +220,7 @@ jobs:
207220
]
208221
include:
209222
# Test minimal supported Rust version
210-
- rust: 1.48.0
223+
- rust: 1.56.0
211224
python-version: "3.11"
212225
platform:
213226
{
@@ -353,6 +366,7 @@ jobs:
353366
conclusion:
354367
needs:
355368
- fmt
369+
- check-msrv
356370
- clippy
357371
- build-pr
358372
- build-full

Cargo.toml

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ categories = ["api-bindings", "development-tools::ffi"]
1212
license = "Apache-2.0"
1313
exclude = ["/.gitignore", ".cargo/config", "/codecov.yml", "/Makefile", "/pyproject.toml", "/noxfile.py", "/.github", "/tests/test_compile_error.rs", "/tests/ui"]
1414
edition = "2018"
15+
rust-version = "1.56"
1516

1617
[dependencies]
1718
cfg-if = "1.0"

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![benchmark](https://github.com/PyO3/pyo3/actions/workflows/bench.yml/badge.svg)](https://pyo3.rs/dev/bench/)
55
[![codecov](https://codecov.io/gh/PyO3/pyo3/branch/main/graph/badge.svg)](https://codecov.io/gh/PyO3/pyo3)
66
[![crates.io](https://img.shields.io/crates/v/pyo3)](https://crates.io/crates/pyo3)
7-
[![minimum rustc 1.48](https://img.shields.io/badge/rustc-1.48+-blue.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html)
7+
[![minimum rustc 1.56](https://img.shields.io/badge/rustc-1.56+-blue.svg)](https://rust-lang.github.io/rfcs/2495-min-rust-version.html)
88
[![dev chat](https://img.shields.io/gitter/room/nwjs/nw.js.svg)](https://gitter.im/PyO3/Lobby)
99
[![contributing notes](https://img.shields.io/badge/contribute-on%20github-Green)](https://github.com/PyO3/pyo3/blob/main/Contributing.md)
1010

@@ -18,7 +18,7 @@
1818

1919
PyO3 supports the following software versions:
2020
- Python 3.7 and up (CPython and PyPy)
21-
- Rust 1.48 and up
21+
- Rust 1.56 and up
2222

2323
You can use PyO3 to write a native Python module in Rust, or to embed Python in a Rust binary. The following sections explain each of these in turn.
2424

examples/plugin/plugin_api/pyproject.toml

-2
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,3 @@ classifiers = [
1010
"Programming Language :: Python :: Implementation :: CPython",
1111
"Programming Language :: Python :: Implementation :: PyPy",
1212
]
13-
14-

guide/src/getting_started.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ To get started using PyO3 you will need three things: a Rust toolchain, a Python
44

55
## Rust
66

7-
First, make sure you have Rust installed on your system. If you haven't already done so, try following the instructions [here](https://www.rust-lang.org/tools/install). PyO3 runs on both the `stable` and `nightly` versions so you can choose whichever one fits you best. The minimum required Rust version is 1.48.
7+
First, make sure you have Rust installed on your system. If you haven't already done so, try following the instructions [here](https://www.rust-lang.org/tools/install). PyO3 runs on both the `stable` and `nightly` versions so you can choose whichever one fits you best. The minimum required Rust version is 1.56.
88

99
If you can run `rustc --version` and the version is new enough you're good to go!
1010

guide/src/migration.md

+6
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@
33
This guide can help you upgrade code through breaking changes from one PyO3 version to the next.
44
For a detailed list of all changes, see the [CHANGELOG](changelog.md).
55

6+
## from 0.19.* to 0.20
7+
8+
### Drop support for older technologies
9+
10+
PyO3 0.20 has increased minimum Rust version to 1.56. This enables use of newer language features and simplifies maintenance of the project.
11+
612
## from 0.18.* to 0.19
713

814
### Access to `Python` inside `__traverse__` implementations are now forbidden

newsfragments/3208.packaging.md

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update MSRV to Rust 1.56.

noxfile.py

+73-66
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from functools import lru_cache
99
from glob import glob
1010
from pathlib import Path
11-
from typing import Any, Dict, List, Optional, Tuple
11+
from typing import Any, Callable, Dict, List, Optional, Tuple
1212

1313
import nox
1414

@@ -96,25 +96,19 @@ def _clippy(session: nox.Session, *, env: Dict[str, str] = None) -> bool:
9696
success = True
9797
env = env or os.environ
9898
for feature_set in _get_feature_sets():
99-
command = "clippy"
100-
extra = ("--", "--deny=warnings")
101-
if _get_rust_version()[:2] == (1, 48):
102-
# 1.48 crashes during clippy because of lints requested
103-
# in .cargo/config
104-
command = "check"
105-
extra = ()
10699
try:
107100
_run(
108101
session,
109102
"cargo",
110-
command,
103+
"clippy",
111104
*feature_set,
112105
"--all-targets",
113106
"--workspace",
114107
# linting pyo3-ffi-check requires docs to have been built or
115108
# the macros will error; doesn't seem worth it on CI
116109
"--exclude=pyo3-ffi-check",
117-
*extra,
110+
"--",
111+
"--deny=warnings",
118112
external=True,
119113
env=env,
120114
)
@@ -126,31 +120,43 @@ def _clippy(session: nox.Session, *, env: Dict[str, str] = None) -> bool:
126120
@nox.session(name="clippy-all", venv_backend="none")
127121
def clippy_all(session: nox.Session) -> None:
128122
success = True
129-
with tempfile.NamedTemporaryFile("r+") as config:
130-
env = os.environ.copy()
131-
env["PYO3_CONFIG_FILE"] = config.name
132-
env["PYO3_CI"] = "1"
133123

134-
def _clippy_with_config(implementation, version) -> bool:
135-
config.seek(0)
136-
config.truncate(0)
137-
config.write(
138-
f"""\
139-
implementation={implementation}
140-
version={version}
141-
suppress_build_script_link_lines=true
142-
"""
143-
)
144-
config.flush()
124+
def _clippy_with_config(env: Dict[str, str]) -> None:
125+
nonlocal success
126+
success &= _clippy(session, env=env)
145127

146-
session.log(f"{implementation} {version}")
147-
return _clippy(session, env=env)
128+
_for_all_version_configs(session, _clippy_with_config)
148129

149-
for version in PY_VERSIONS:
150-
success &= _clippy_with_config("CPython", version)
130+
if not success:
131+
session.error("one or more jobs failed")
151132

152-
for version in PYPY_VERSIONS:
153-
success &= _clippy_with_config("PyPy", version)
133+
134+
@nox.session(name="check-all", venv_backend="none")
135+
def check_all(session: nox.Session) -> None:
136+
success = True
137+
138+
def _check(env: Dict[str, str]) -> None:
139+
nonlocal success
140+
env = env or os.environ
141+
for feature_set in _get_feature_sets():
142+
try:
143+
_run(
144+
session,
145+
"cargo",
146+
"check",
147+
*feature_set,
148+
"--all-targets",
149+
"--workspace",
150+
# linting pyo3-ffi-check requires docs to have been built or
151+
# the macros will error; doesn't seem worth it on CI
152+
"--exclude=pyo3-ffi-check",
153+
external=True,
154+
env=env,
155+
)
156+
except Exception:
157+
success = False
158+
159+
_for_all_version_configs(session, _check)
154160

155161
if not success:
156162
session.error("one or more jobs failed")
@@ -422,42 +428,13 @@ def set_minimal_package_versions(session: nox.Session):
422428
"examples/word-count",
423429
)
424430
min_pkg_versions = {
425-
# newer versions of rust_decimal want newer arrayvec
426-
"rust_decimal": "1.18.0",
427-
# newer versions of arrayvec use const generics (Rust 1.51+)
428-
"arrayvec": "0.5.2",
431+
"rust_decimal": "1.26.1",
429432
"csv": "1.1.6",
430-
# newer versions of chrono use i32::rem_euclid as a const fn
431-
"chrono": "0.4.24",
432-
"indexmap": "1.6.2",
433-
"inventory": "0.3.4",
434-
"hashbrown": "0.9.1",
435-
"plotters": "0.3.1",
436-
"plotters-svg": "0.3.1",
437-
"plotters-backend": "0.3.2",
438-
"bumpalo": "3.10.0",
439-
"once_cell": "1.14.0",
440-
"rayon": "1.5.3",
441-
"rayon-core": "1.9.3",
433+
"hashbrown": "0.12.3",
434+
"once_cell": "1.17.2",
435+
"rayon": "1.6.1",
436+
"rayon-core": "1.10.2",
442437
"regex": "1.7.3",
443-
# string_cache 0.8.4 depends on parking_lot 0.12
444-
"string_cache": "0.8.3",
445-
# 1.15.0 depends on hermit-abi 0.2.6 which has edition 2021 and breaks 1.48.0
446-
"num_cpus": "1.14.0",
447-
"parking_lot": "0.11.0",
448-
# 1.0.77 needs basic-toml which has edition 2021
449-
"trybuild": "1.0.76",
450-
# pins to avoid syn 2.0 (which requires Rust 1.56)
451-
"ghost": "0.1.8",
452-
"serde": "1.0.156",
453-
"serde_derive": "1.0.156",
454-
"cxx": "1.0.92",
455-
"cxxbridge-macro": "1.0.92",
456-
"cxx-build": "1.0.92",
457-
"web-sys": "0.3.61",
458-
"js-sys": "0.3.61",
459-
"wasm-bindgen": "0.2.84",
460-
"syn": "1.0.109",
461438
}
462439

463440
# run cargo update first to ensure that everything is at highest
@@ -634,11 +611,41 @@ def _run_cargo_set_package_version(
634611
*,
635612
project: Optional[str] = None,
636613
) -> None:
637-
command = ["cargo", "update", "-p", pkg_id, "--precise", version]
614+
command = ["cargo", "update", "-p", pkg_id, "--precise", version, "--workspace"]
638615
if project:
639616
command.append(f"--manifest-path={project}/Cargo.toml")
640617
_run(session, *command, external=True)
641618

642619

643620
def _get_output(*args: str) -> str:
644621
return subprocess.run(args, capture_output=True, text=True, check=True).stdout
622+
623+
624+
def _for_all_version_configs(
625+
session: nox.Session, job: Callable[[Dict[str, str]], None]
626+
) -> None:
627+
with tempfile.NamedTemporaryFile("r+") as config:
628+
env = os.environ.copy()
629+
env["PYO3_CONFIG_FILE"] = config.name
630+
env["PYO3_CI"] = "1"
631+
632+
def _job_with_config(implementation, version) -> bool:
633+
config.seek(0)
634+
config.truncate(0)
635+
config.write(
636+
f"""\
637+
implementation={implementation}
638+
version={version}
639+
suppress_build_script_link_lines=true
640+
"""
641+
)
642+
config.flush()
643+
644+
session.log(f"{implementation} {version}")
645+
return job(env)
646+
647+
for version in PY_VERSIONS:
648+
_job_with_config("CPython", version)
649+
650+
for version in PYPY_VERSIONS:
651+
_job_with_config("PyPy", version)

pyo3-build-config/src/lib.rs

+5
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,11 @@ pub fn print_feature_cfgs() {
161161
if rustc_minor_version >= 59 {
162162
println!("cargo:rustc-cfg=thread_local_const_init");
163163
}
164+
165+
// Enable use of `#[cfg(panic = "...")]` on Rust 1.60 and greater
166+
if rustc_minor_version >= 60 {
167+
println!("cargo:rustc-cfg=panic_unwind");
168+
}
164169
}
165170

166171
/// Private exports used in PyO3's build.rs

pyo3-ffi/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Manual][capi] for up-to-date documentation.
1414

1515
PyO3 supports the following software versions:
1616
- Python 3.7 and up (CPython and PyPy)
17-
- Rust 1.48 and up
17+
- Rust 1.56 and up
1818

1919
# Example: Building Python Native modules
2020

pyo3-ffi/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
//!
5252
//! PyO3 supports the following software versions:
5353
//! - Python 3.7 and up (CPython and PyPy)
54-
//! - Rust 1.48 and up
54+
//! - Rust 1.56 and up
5555
//!
5656
//! # Example: Building Python Native modules
5757
//!

pyo3-macros-backend/src/pyfunction/signature.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ pub struct Signature {
2727
impl Parse for Signature {
2828
fn parse(input: ParseStream<'_>) -> syn::Result<Self> {
2929
let content;
30-
Ok(Signature {
31-
paren_token: syn::parenthesized!(content in input),
32-
items: content.parse_terminated(SignatureItem::parse)?,
33-
})
30+
let paren_token = syn::parenthesized!(content in input);
31+
32+
let items = content.parse_terminated(SignatureItem::parse)?;
33+
34+
Ok(Signature { paren_token, items })
3435
}
3536
}
3637

0 commit comments

Comments
 (0)