-
Notifications
You must be signed in to change notification settings - Fork 805
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add supported CPython/PyPy versions to cargo package metadata. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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"]) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Good point, I think have it only on a leaf dependency makes sense! |
||
|
||
_run_cargo_test(session, package="pyo3-build-config") | ||
_run_cargo_test(session, package="pyo3-macros-backend") | ||
_run_cargo_test(session, package="pyo3-macros") | ||
|
@@ -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 | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder, can we generate
PY_VERSIONS
andPYPY_VERSIONS
in this file from the metadata?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds doable.