Add support for GraalPy (#5380)

* Initial support for GraalPy

* Mark tests that currently fail on GraalPy with xfail

* Add graalpy to CI

* Limit test deps on graalpy to available binary wheels

* Skip cmake test installed_function on GraalPy

CMake won't find libpython on GraalPy, it either fails or silently picks
CPython's libpython.

* Factor out setting function docstrings into a macro

* Try to narrow down skipped tests
This commit is contained in:
Michael Šimáček
2024-10-07 23:12:04 +02:00
committed by GitHub
parent 7e418f4924
commit c4a05f9344
42 changed files with 211 additions and 66 deletions

View File

@@ -4,11 +4,13 @@ import re
import pytest
import env # noqa: F401
from pybind11_tests import ConstructorStats
from pybind11_tests import factory_constructors as m
from pybind11_tests.factory_constructors import tag
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
def test_init_factory_basic():
"""Tests py::init_factory() wrapper around various ways of returning the object"""
@@ -102,6 +104,7 @@ def test_init_factory_signature(msg):
)
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
def test_init_factory_casting():
"""Tests py::init_factory() wrapper with various upcasting and downcasting returns"""
@@ -150,6 +153,7 @@ def test_init_factory_casting():
]
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
def test_init_factory_alias():
"""Tests py::init_factory() wrapper with value conversions and alias types"""
@@ -220,6 +224,7 @@ def test_init_factory_alias():
]
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
def test_init_factory_dual():
"""Tests init factory functions with dual main/alias factory functions"""
from pybind11_tests.factory_constructors import TestFactory7
@@ -302,6 +307,7 @@ def test_init_factory_dual():
]
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
def test_no_placement_new(capture):
"""Prior to 2.2, `py::init<...>` relied on the type supporting placement
new; this tests a class without placement new support."""
@@ -350,6 +356,7 @@ def strip_comments(s):
return re.sub(r"\s+#.*", "", s)
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
def test_reallocation_a(capture, msg):
"""When the constructor is overloaded, previous overloads can require a preallocated value.
This test makes sure that such preallocated values only happen when they might be necessary,
@@ -372,6 +379,7 @@ def test_reallocation_a(capture, msg):
)
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
def test_reallocation_b(capture, msg):
with capture:
create_and_destroy(1.5)
@@ -388,6 +396,7 @@ def test_reallocation_b(capture, msg):
)
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
def test_reallocation_c(capture, msg):
with capture:
create_and_destroy(2, 3)
@@ -402,6 +411,7 @@ def test_reallocation_c(capture, msg):
)
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
def test_reallocation_d(capture, msg):
with capture:
create_and_destroy(2.5, 3)
@@ -417,6 +427,7 @@ def test_reallocation_d(capture, msg):
)
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
def test_reallocation_e(capture, msg):
with capture:
create_and_destroy(3.5, 4.5)
@@ -432,6 +443,7 @@ def test_reallocation_e(capture, msg):
)
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
def test_reallocation_f(capture, msg):
with capture:
create_and_destroy(4, 0.5)
@@ -448,6 +460,7 @@ def test_reallocation_f(capture, msg):
)
@pytest.mark.skipif("env.GRAALPY", reason="Cannot reliably trigger GC")
def test_reallocation_g(capture, msg):
with capture:
create_and_destroy(5, "hi")