From 9cd9b245631385e06f7cadd587c0ea252a0aa1ba Mon Sep 17 00:00:00 2001 From: messense Date: Sun, 27 Mar 2022 21:43:26 +0800 Subject: [PATCH] Run pytests and examples with pep489 feature on --- examples/decorator/noxfile.py | 7 +++++-- examples/maturin-starter/noxfile.py | 7 +++++-- examples/word-count/noxfile.py | 7 +++++-- pytests/Cargo.toml | 3 +++ pytests/noxfile.py | 7 +++++-- 5 files changed, 23 insertions(+), 8 deletions(-) diff --git a/examples/decorator/noxfile.py b/examples/decorator/noxfile.py index 17a6b80f3f5..ff2195ede10 100644 --- a/examples/decorator/noxfile.py +++ b/examples/decorator/noxfile.py @@ -2,8 +2,11 @@ @nox.session -def python(session): +@nox.parametrize("cargo_features", ['""', "pep489"]) +def python(session, cargo_features): session.install("-rrequirements-dev.txt") session.install("maturin") - session.run_always("maturin", "develop") + session.run_always( + "maturin", "develop", f"--cargo-extra-args=--features {cargo_features}" + ) session.run("pytest") diff --git a/examples/maturin-starter/noxfile.py b/examples/maturin-starter/noxfile.py index 17a6b80f3f5..ff2195ede10 100644 --- a/examples/maturin-starter/noxfile.py +++ b/examples/maturin-starter/noxfile.py @@ -2,8 +2,11 @@ @nox.session -def python(session): +@nox.parametrize("cargo_features", ['""', "pep489"]) +def python(session, cargo_features): session.install("-rrequirements-dev.txt") session.install("maturin") - session.run_always("maturin", "develop") + session.run_always( + "maturin", "develop", f"--cargo-extra-args=--features {cargo_features}" + ) session.run("pytest") diff --git a/examples/word-count/noxfile.py b/examples/word-count/noxfile.py index 39230d2609b..0b979e1aa67 100644 --- a/examples/word-count/noxfile.py +++ b/examples/word-count/noxfile.py @@ -4,10 +4,13 @@ @nox.session -def test(session): +@nox.parametrize("cargo_features", ['""', "pep489"]) +def test(session, cargo_features): session.install("-rrequirements-dev.txt") session.install("maturin") - session.run_always("maturin", "develop") + session.run_always( + "maturin", "develop", f"--cargo-extra-args=--features {cargo_features}" + ) session.run("pytest") diff --git a/pytests/Cargo.toml b/pytests/Cargo.toml index 1e387ca229b..bff0068e4fa 100644 --- a/pytests/Cargo.toml +++ b/pytests/Cargo.toml @@ -15,6 +15,9 @@ pyo3-build-config = { path = "../pyo3-build-config" } name = "pyo3_pytests" crate-type = ["cdylib"] +[features] +pep489 = ["pyo3/pep489"] + [package.metadata.maturin] classifier=[ "License :: OSI Approved :: MIT License", diff --git a/pytests/noxfile.py b/pytests/noxfile.py index 22d0691f92a..2c28634049e 100644 --- a/pytests/noxfile.py +++ b/pytests/noxfile.py @@ -4,10 +4,13 @@ @nox.session -def test(session): +@nox.parametrize("cargo_features", ['""', "pep489"]) +def test(session, cargo_features): session.install("-rrequirements-dev.txt") session.install("maturin") - session.run_always("maturin", "develop") + session.run_always( + "maturin", "develop", f"--cargo-extra-args=--features {cargo_features}" + ) session.run("pytest")