ci: update to GraalPy 24.2 and mention in README (#5586)

* ci: update to GraalPy 24.2 and mention in README

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* tests: update for GRAALPY 24.2 and better printout

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* tests: use __graalpython__ for version number

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* Update README.rst

---------

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
This commit is contained in:
Henry Schreiner
2025-03-31 22:50:55 -04:00
committed by GitHub
parent d27fdaa272
commit 8ef10a0ec9
6 changed files with 58 additions and 24 deletions

View File

@@ -38,7 +38,7 @@ jobs:
- '3.13' - '3.13'
- 'pypy-3.10' - 'pypy-3.10'
- 'pypy-3.11' - 'pypy-3.11'
- 'graalpy-24.1' - 'graalpy-24.2'
# Items in here will either be added to the build matrix (if not # Items in here will either be added to the build matrix (if not
# present), or add new keys to an existing matrix element if all the # present), or add new keys to an existing matrix element if all the
@@ -95,9 +95,12 @@ jobs:
python: '3.12' python: '3.12'
args: > args: >
-DCMAKE_CXX_FLAGS="/DPYBIND11_RUN_TESTING_WITH_SMART_HOLDER_AS_DEFAULT_BUT_NEVER_USE_IN_PRODUCTION_PLEASE /GR /EHsc" -DCMAKE_CXX_FLAGS="/DPYBIND11_RUN_TESTING_WITH_SMART_HOLDER_AS_DEFAULT_BUT_NEVER_USE_IN_PRODUCTION_PLEASE /GR /EHsc"
- python: 'graalpy-24.1'
runs-on: 'ubuntu-latest'
exclude: exclude:
# The setup-python action currently doesn't have graalpy for windows # The setup-python action currently doesn't have graalpy for windows
- python: 'graalpy-24.1' # See https://github.com/actions/setup-python/pull/880
- python: 'graalpy-24.2'
runs-on: 'windows-2022' runs-on: 'windows-2022'

View File

@@ -34,12 +34,12 @@ dependency.
Think of this library as a tiny self-contained version of Boost.Python Think of this library as a tiny self-contained version of Boost.Python
with everything stripped away that isn't relevant for binding with everything stripped away that isn't relevant for binding
generation. Without comments, the core header files only require ~4K generation. Without comments, the core header files only require ~4K
lines of code and depend on Python (3.8+, or PyPy) and the C++ lines of code and depend on Python (CPython 3.8+, PyPy, or GraalPy) and the C++
standard library. This compact implementation was possible thanks to standard library. This compact implementation was possible thanks to some C++11
some C++11 language features (specifically: tuples, lambda functions and language features (specifically: tuples, lambda functions and variadic
variadic templates). Since its creation, this library has grown beyond templates). Since its creation, this library has grown beyond Boost.Python in
Boost.Python in many ways, leading to dramatically simpler binding code in many many ways, leading to dramatically simpler binding code in many common
common situations. situations.
Tutorial and reference documentation is provided at Tutorial and reference documentation is provided at
`pybind11.readthedocs.io <https://pybind11.readthedocs.io/en/latest>`_. `pybind11.readthedocs.io <https://pybind11.readthedocs.io/en/latest>`_.
@@ -79,8 +79,9 @@ Goodies
In addition to the core functionality, pybind11 provides some extra In addition to the core functionality, pybind11 provides some extra
goodies: goodies:
- Python 3.8+, and PyPy3 7.3 are supported with an implementation-agnostic - Python 3.8+, PyPy3 7.3.17+, and GraalPy 24.1+ are supported with an
interface (pybind11 2.9 was the last version to support Python 2 and 3.5). implementation-agnostic interface (pybind11 2.9 was the last version to
support Python 2 and 3.5).
- It is possible to bind C++11 lambda functions with captured - It is possible to bind C++11 lambda functions with captured
variables. The lambda capture data is stored inside the resulting variables. The lambda capture data is stored inside the resulting

View File

@@ -9,9 +9,11 @@ from __future__ import annotations
import contextlib import contextlib
import difflib import difflib
import gc import gc
import importlib.metadata
import multiprocessing import multiprocessing
import re import re
import sys import sys
import sysconfig
import textwrap import textwrap
import traceback import traceback
@@ -210,16 +212,34 @@ def pytest_configure():
pytest.gc_collect = gc_collect pytest.gc_collect = gc_collect
def pytest_report_header(config): def pytest_report_header():
del config # Unused.
assert pybind11_tests.compiler_info is not None, ( assert pybind11_tests.compiler_info is not None, (
"Please update pybind11_tests.cpp if this assert fails." "Please update pybind11_tests.cpp if this assert fails."
) )
return ( interesting_packages = ("pybind11", "numpy", "scipy", "build")
"C++ Info:" valid = []
f" {pybind11_tests.compiler_info}" for package in sorted(interesting_packages):
f" {pybind11_tests.cpp_std}" with contextlib.suppress(ModuleNotFoundError):
f" {pybind11_tests.PYBIND11_INTERNALS_ID}" valid.append(f"{package}=={importlib.metadata.version(package)}")
f" PYBIND11_SIMPLE_GIL_MANAGEMENT={pybind11_tests.PYBIND11_SIMPLE_GIL_MANAGEMENT}" reqs = " ".join(valid)
f" PYBIND11_NUMPY_1_ONLY={pybind11_tests.PYBIND11_NUMPY_1_ONLY}"
) cpp_info = [
"C++ Info:",
f"{pybind11_tests.compiler_info}",
f"{pybind11_tests.cpp_std}",
f"{pybind11_tests.PYBIND11_INTERNALS_ID}",
f"PYBIND11_SIMPLE_GIL_MANAGEMENT={pybind11_tests.PYBIND11_SIMPLE_GIL_MANAGEMENT}",
f"PYBIND11_NUMPY_1_ONLY={pybind11_tests.PYBIND11_NUMPY_1_ONLY}",
]
if "__graalpython__" in sys.modules:
cpp_info.append(
f"GraalPy version: {sys.modules['__graalpython__'].get_graalvm_version()}"
)
lines = [
f"installed packages of interest: {reqs}",
" ".join(cpp_info),
]
if sysconfig.get_config_var("Py_GIL_DISABLED"):
lines.append("free-threaded Python build")
return lines

View File

@@ -13,6 +13,10 @@ WIN = sys.platform.startswith("win32") or sys.platform.startswith("cygwin")
CPYTHON = platform.python_implementation() == "CPython" CPYTHON = platform.python_implementation() == "CPython"
PYPY = platform.python_implementation() == "PyPy" PYPY = platform.python_implementation() == "PyPy"
GRAALPY = sys.implementation.name == "graalpy" GRAALPY = sys.implementation.name == "graalpy"
_graalpy_version = (
sys.modules["__graalpython__"].get_graalvm_version() if GRAALPY else "0.0.0"
)
GRAALPY_VERSION = tuple(int(t) for t in _graalpy_version.split(".")[:3])
PY_GIL_DISABLED = bool(sysconfig.get_config_var("Py_GIL_DISABLED")) PY_GIL_DISABLED = bool(sysconfig.get_config_var("Py_GIL_DISABLED"))

View File

@@ -5,11 +5,13 @@ import re
import pytest import pytest
import env # noqa: F401 import env
from pybind11_tests import enums as m from pybind11_tests import enums as m
@pytest.mark.xfail("env.GRAALPY", reason="TODO should get fixed on GraalPy side") @pytest.mark.xfail(
env.GRAALPY and env.GRAALPY_VERSION < (24, 2), reason="Fixed in GraalPy 24.2"
)
def test_unscoped_enum(): def test_unscoped_enum():
assert str(m.UnscopedEnum.EOne) == "UnscopedEnum.EOne" assert str(m.UnscopedEnum.EOne) == "UnscopedEnum.EOne"
assert str(m.UnscopedEnum.ETwo) == "UnscopedEnum.ETwo" assert str(m.UnscopedEnum.ETwo) == "UnscopedEnum.ETwo"
@@ -197,7 +199,9 @@ def test_implicit_conversion():
assert repr(x) == "{<EMode.EFirstMode: 1>: 3, <EMode.ESecondMode: 2>: 4}" assert repr(x) == "{<EMode.EFirstMode: 1>: 3, <EMode.ESecondMode: 2>: 4}"
@pytest.mark.xfail("env.GRAALPY", reason="TODO should get fixed on GraalPy side") @pytest.mark.xfail(
env.GRAALPY and env.GRAALPY_VERSION < (24, 2), reason="Fixed in GraalPy 24.2"
)
def test_binary_operators(): def test_binary_operators():
assert int(m.Flags.Read) == 4 assert int(m.Flags.Read) == 4
assert int(m.Flags.Write) == 2 assert int(m.Flags.Write) == 2

View File

@@ -88,7 +88,9 @@ def test_operator_overloading():
assert cstats.move_assignments == 0 assert cstats.move_assignments == 0
@pytest.mark.xfail("env.GRAALPY", reason="TODO should get fixed on GraalPy side") @pytest.mark.xfail(
env.GRAALPY and env.GRAALPY_VERSION < (24, 2), reason="Fixed in GraalPy 24.2"
)
def test_operators_notimplemented(): def test_operators_notimplemented():
"""#393: need to return NotSupported to ensure correct arithmetic operator behavior""" """#393: need to return NotSupported to ensure correct arithmetic operator behavior"""