Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add supported CPython/PyPy versions to cargo package metadata #4756

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ hashbrown = { version = ">= 0.14.5, < 0.16", optional = true }
indexmap = { version = ">= 2.5.0, < 3", optional = true }
num-bigint = { version = "0.4.2", optional = true }
num-complex = { version = ">= 0.4.6, < 0.5", optional = true }
num-rational = {version = "0.4.1", optional = true }
num-rational = { version = "0.4.1", optional = true }
rust_decimal = { version = "1.15", default-features = false, optional = true }
serde = { version = "1.0", optional = true }
smallvec = { version = "1.0", optional = true }
Expand All @@ -63,7 +63,7 @@ rayon = "1.6.1"
futures = "0.3.28"
tempfile = "3.12.0"
static_assertions = "1.1.0"
uuid = {version = "1.10.0", features = ["v4"] }
uuid = { version = "1.10.0", features = ["v4"] }

[build-dependencies]
pyo3-build-config = { path = "pyo3-build-config", version = "=0.23.2", features = ["resolve-config"] }
Expand Down Expand Up @@ -150,6 +150,14 @@ no-default-features = true
features = ["full"]
rustdoc-args = ["--cfg", "docsrs"]

[package.metadata.cpython]
min-version = "3.7"
max-version = "3.13" # inclusive

[package.metadata.pypy]
min-version = "3.9"
max-version = "3.10" # inclusive

[workspace.lints.clippy]
checked_conversions = "warn"
dbg_macro = "warn"
Expand Down
1 change: 1 addition & 0 deletions newsfragments/4756.packaging.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add supported CPython/PyPy versions to cargo package metadata.
18 changes: 18 additions & 0 deletions noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def test(session: nox.Session) -> None:

@nox.session(name="test-rust", venv_backend="none")
def test_rust(session: nox.Session):
_run_cargo_package_metadata_test(session, packages=["pyo3", "pyo3-ffi"])

_run_cargo_test(session, package="pyo3-build-config")
_run_cargo_test(session, package="pyo3-macros-backend")
_run_cargo_test(session, package="pyo3-macros")
Expand Down Expand Up @@ -914,6 +916,22 @@ def _run_cargo_set_package_version(
_run(session, *command, external=True)


def _run_cargo_package_metadata_test(
session: nox.Session, *, packages: List[str]
) -> None:
output = _get_output("cargo", "metadata", "--format-version=1", "--no-deps")
cargo_packages = json.loads(output)["packages"]
for package in packages:
# Check Python interpreter version support in package metadata
metadata = next(
pkg["metadata"] for pkg in cargo_packages if pkg["name"] == package
)
for python_impl in ["cpython", "pypy"]:
version_info = metadata[python_impl]
assert "min-version" in version_info
assert "max-version" in version_info


def _get_output(*args: str) -> str:
return subprocess.run(args, capture_output=True, text=True, check=True).stdout

Expand Down
8 changes: 8 additions & 0 deletions pyo3-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,11 @@ pyo3-build-config = { path = "../pyo3-build-config", version = "=0.23.2", featur

[lints]
workspace = true

[package.metadata.cpython]
min-version = "3.7"
max-version = "3.13" # inclusive

[package.metadata.pypy]
min-version = "3.9"
max-version = "3.10" # inclusive
Loading