File tree Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Expand file tree Collapse file tree 3 files changed +40
-1
lines changed Original file line number Diff line number Diff line change 3838# define PYBIND11_CPP17
3939# if __cplusplus >= 202002L
4040# define PYBIND11_CPP20
41+ // Please update tests/pybind11_tests.cpp `cpp_std()` when adding a macro here.
4142# endif
4243# endif
4344# endif
Original file line number Diff line number Diff line change 1313import pytest
1414
1515# Early diagnostic for failed imports
16- import pybind11_tests # noqa: F401
16+ import pybind11_tests
1717
1818_long_marker = re .compile (r"([0-9])L" )
1919_hexadecimal = re .compile (r"0x[0-9a-fA-F]+" )
@@ -198,3 +198,16 @@ def gc_collect():
198198def pytest_configure ():
199199 pytest .suppress = suppress
200200 pytest .gc_collect = gc_collect
201+
202+
203+ def pytest_report_header (config ):
204+ del config # Unused.
205+ assert (
206+ pybind11_tests .compiler_info is not None
207+ ), "Please update pybind11_tests.cpp if this assert fails."
208+ return (
209+ "C++ Info:"
210+ f" { pybind11_tests .compiler_info } "
211+ f" { pybind11_tests .cpp_std } "
212+ f" { pybind11_tests .PYBIND11_INTERNALS_ID } "
213+ )
Original file line number Diff line number Diff line change @@ -62,9 +62,34 @@ void bind_ConstructorStats(py::module_ &m) {
6262 });
6363}
6464
65+ const char *cpp_std () {
66+ return
67+ #if defined(PYBIND11_CPP20)
68+ " C++20" ;
69+ #elif defined(PYBIND11_CPP17)
70+ " C++17" ;
71+ #elif defined(PYBIND11_CPP14)
72+ " C++14" ;
73+ #else
74+ " C++11" ;
75+ #endif
76+ }
77+
6578PYBIND11_MODULE (pybind11_tests, m) {
6679 m.doc () = " pybind11 test module" ;
6780
81+ // Intentionally kept minimal to not create a maintenance chore
82+ // ("just enough" to be conclusive).
83+ #if defined(_MSC_FULL_VER)
84+ m.attr (" compiler_info" ) = " MSVC " PYBIND11_TOSTRING (_MSC_FULL_VER);
85+ #elif defined(__VERSION__)
86+ m.attr (" compiler_info" ) = __VERSION__;
87+ #else
88+ m.attr (" compiler_info" ) = py::none ();
89+ #endif
90+ m.attr (" cpp_std" ) = cpp_std ();
91+ m.attr (" PYBIND11_INTERNALS_ID" ) = PYBIND11_INTERNALS_ID;
92+
6893 bind_ConstructorStats (m);
6994
7095#if defined(PYBIND11_DETAILED_ERROR_MESSAGES)
You can’t perform that action at this time.
0 commit comments