File tree 3 files changed +40
-1
lines changed 3 files changed +40
-1
lines changed Original file line number Diff line number Diff line change 38
38
# define PYBIND11_CPP17
39
39
# if __cplusplus >= 202002L
40
40
# define PYBIND11_CPP20
41
+ // Please update tests/pybind11_tests.cpp `cpp_std()` when adding a macro here.
41
42
# endif
42
43
# endif
43
44
# endif
Original file line number Diff line number Diff line change 13
13
import pytest
14
14
15
15
# Early diagnostic for failed imports
16
- import pybind11_tests # noqa: F401
16
+ import pybind11_tests
17
17
18
18
_long_marker = re .compile (r"([0-9])L" )
19
19
_hexadecimal = re .compile (r"0x[0-9a-fA-F]+" )
@@ -198,3 +198,16 @@ def gc_collect():
198
198
def pytest_configure ():
199
199
pytest .suppress = suppress
200
200
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) {
62
62
});
63
63
}
64
64
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
+
65
78
PYBIND11_MODULE (pybind11_tests, m) {
66
79
m.doc () = " pybind11 test module" ;
67
80
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
+
68
93
bind_ConstructorStats (m);
69
94
70
95
#if defined(PYBIND11_DETAILED_ERROR_MESSAGES)
You can’t perform that action at this time.
0 commit comments