From d26ad7ba11d8a314c9254537c3b62bbcae808141 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sat, 14 Sep 2024 10:57:16 -0700 Subject: [PATCH 01/13] Factor out pybind11/compat/wrap_include_python_h.h --- CMakeLists.txt | 1 + .../pybind11/compat/wrap_include_python_h.h | 69 +++++++++++++++++++ include/pybind11/detail/common.h | 62 ++--------------- tests/extra_python_package/test_files.py | 6 +- 4 files changed, 80 insertions(+), 58 deletions(-) create mode 100644 include/pybind11/compat/wrap_include_python_h.h diff --git a/CMakeLists.txt b/CMakeLists.txt index b088eb55f5..6e894e2104 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,6 +142,7 @@ set(PYBIND11_HEADERS include/pybind11/cast.h include/pybind11/chrono.h include/pybind11/common.h + include/pybind11/compat/wrap_include_python_h.h include/pybind11/complex.h include/pybind11/options.h include/pybind11/eigen.h diff --git a/include/pybind11/compat/wrap_include_python_h.h b/include/pybind11/compat/wrap_include_python_h.h new file mode 100644 index 0000000000..76bf680bf5 --- /dev/null +++ b/include/pybind11/compat/wrap_include_python_h.h @@ -0,0 +1,69 @@ +#pragma once + +// Copyright (c) 2024 The pybind Community. + +// STRONG REQUIREMENT: +// This header is a wrapper around `#include `, therefore it +// MUST BE INCLUDED BEFORE ANY STANDARD HEADERS are included. +// See also: +// https://docs.python.org/3/c-api/intro.html#include-files +// Quoting from there: +// Note: Since Python may define some pre-processor definitions which affect +// the standard headers on some systems, you must include Python.h before +// any standard headers are included. + +// Disable linking to pythonX_d.lib on Windows in debug mode. +#if defined(_MSC_VER) && defined(_DEBUG) && !defined(Py_DEBUG) +// Workaround for a VS 2022 issue. +// See https://github.com/pybind/pybind11/pull/3497 for full context. +// NOTE: This workaround knowingly violates the Python.h include order +// requirement (see above). +# include +# if _MSVC_STL_VERSION >= 143 +# include +# endif +# define PYBIND11_DEBUG_MARKER +# undef _DEBUG +#endif + +// Don't let Python.h #define (v)snprintf as macro because they are implemented +// properly in Visual Studio since 2015. +#if defined(_MSC_VER) +# define HAVE_SNPRINTF 1 +#endif + +#if defined(_MSC_VER) +# pragma warning(push) +# pragma warning(disable : 4505) +// C4505: 'PySlice_GetIndicesEx': unreferenced local function has been removed +#endif + +#include +#include +#include + +#if defined(_MSC_VER) +# pragma warning(pop) +#endif + +#if defined(PYBIND11_DEBUG_MARKER) +# define _DEBUG +# undef PYBIND11_DEBUG_MARKER +#endif + +// Python #defines overrides on all sorts of core functions, which +// tends to wreak havok in C++ codebases that expect these to work +// like regular functions (potentially with several overloads). +#if defined(isalnum) +# undef isalnum +# undef isalpha +# undef islower +# undef isspace +# undef isupper +# undef tolower +# undef toupper +#endif + +#if defined(copysign) +# undef copysign +#endif diff --git a/include/pybind11/detail/common.h b/include/pybind11/detail/common.h index 2a39e88f37..ac73dfe0c4 100644 --- a/include/pybind11/detail/common.h +++ b/include/pybind11/detail/common.h @@ -9,6 +9,11 @@ #pragma once +#include +#if PY_VERSION_HEX < 0x03080000 +# error "PYTHON < 3.8 IS UNSUPPORTED. pybind11 v2.13 was the last to support Python 3.7." +#endif + #define PYBIND11_VERSION_MAJOR 2 #define PYBIND11_VERSION_MINOR 14 #define PYBIND11_VERSION_PATCH 0.dev1 @@ -212,31 +217,6 @@ # define PYBIND11_MAYBE_UNUSED __attribute__((__unused__)) #endif -/* Don't let Python.h #define (v)snprintf as macro because they are implemented - properly in Visual Studio since 2015. */ -#if defined(_MSC_VER) -# define HAVE_SNPRINTF 1 -#endif - -/// Include Python header, disable linking to pythonX_d.lib on Windows in debug mode -#if defined(_MSC_VER) -PYBIND11_WARNING_PUSH -PYBIND11_WARNING_DISABLE_MSVC(4505) -// C4505: 'PySlice_GetIndicesEx': unreferenced local function has been removed (PyPy only) -# if defined(_DEBUG) && !defined(Py_DEBUG) -// Workaround for a VS 2022 issue. -// NOTE: This workaround knowingly violates the Python.h include order requirement: -// https://docs.python.org/3/c-api/intro.html#include-files -// See https://github.com/pybind/pybind11/pull/3497 for full context. -# include -# if _MSVC_STL_VERSION >= 143 -# include -# endif -# define PYBIND11_DEBUG_MARKER -# undef _DEBUG -# endif -#endif - // https://en.cppreference.com/w/c/chrono/localtime #if defined(__STDC_LIB_EXT1__) && !defined(__STDC_WANT_LIB_EXT1__) # define __STDC_WANT_LIB_EXT1__ @@ -271,30 +251,6 @@ PYBIND11_WARNING_DISABLE_MSVC(4505) # endif #endif -#include -#if PY_VERSION_HEX < 0x03080000 -# error "PYTHON < 3.8 IS UNSUPPORTED. pybind11 v2.13 was the last to support Python 3.7." -#endif -#include -#include - -/* Python #defines overrides on all sorts of core functions, which - tends to weak havok in C++ codebases that expect these to work - like regular functions (potentially with several overloads) */ -#if defined(isalnum) -# undef isalnum -# undef isalpha -# undef islower -# undef isspace -# undef isupper -# undef tolower -# undef toupper -#endif - -#if defined(copysign) -# undef copysign -#endif - #if defined(PYBIND11_NUMPY_1_ONLY) # define PYBIND11_INTERNAL_NUMPY_1_ONLY_DETECTED #endif @@ -303,14 +259,6 @@ PYBIND11_WARNING_DISABLE_MSVC(4505) # define PYBIND11_SIMPLE_GIL_MANAGEMENT #endif -#if defined(_MSC_VER) -# if defined(PYBIND11_DEBUG_MARKER) -# define _DEBUG -# undef PYBIND11_DEBUG_MARKER -# endif -PYBIND11_WARNING_POP -#endif - #include #include #include diff --git a/tests/extra_python_package/test_files.py b/tests/extra_python_package/test_files.py index cb11933a70..c9e87ba767 100644 --- a/tests/extra_python_package/test_files.py +++ b/tests/extra_python_package/test_files.py @@ -50,6 +50,10 @@ "include/pybind11/warnings.h", } +compat_headers = { + "include/pybind11/compat/wrap_include_python_h.h", +} + detail_headers = { "include/pybind11/detail/class.h", "include/pybind11/detail/common.h", @@ -97,7 +101,7 @@ "setup_helpers.py", } -headers = main_headers | detail_headers | eigen_headers | stl_headers +headers = main_headers | compat_headers | detail_headers | eigen_headers | stl_headers src_files = headers | cmake_files | pkgconfig_files all_files = src_files | py_files From d5e38f121f4ba9aacbce0e0439f788b2fac2f118 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sat, 14 Sep 2024 22:39:05 -0700 Subject: [PATCH 02/13] Fixes to resolve tests_packaging failures. --- tests/extra_python_package/test_files.py | 1 + tools/setup_global.py.in | 4 +++- tools/setup_main.py.in | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/extra_python_package/test_files.py b/tests/extra_python_package/test_files.py index c9e87ba767..9f91149888 100644 --- a/tests/extra_python_package/test_files.py +++ b/tests/extra_python_package/test_files.py @@ -110,6 +110,7 @@ "pybind11", "pybind11/include", "pybind11/include/pybind11", + "pybind11/include/pybind11/compat", "pybind11/include/pybind11/detail", "pybind11/include/pybind11/eigen", "pybind11/include/pybind11/stl", diff --git a/tools/setup_global.py.in b/tools/setup_global.py.in index 885ac5c725..7d22a71e18 100644 --- a/tools/setup_global.py.in +++ b/tools/setup_global.py.in @@ -26,12 +26,13 @@ class InstallHeadersNested(install_headers): main_headers = glob.glob("pybind11/include/pybind11/*.h") +compat_headers = glob.glob("pybind11/include/pybind11/compat/*.h") detail_headers = glob.glob("pybind11/include/pybind11/detail/*.h") eigen_headers = glob.glob("pybind11/include/pybind11/eigen/*.h") stl_headers = glob.glob("pybind11/include/pybind11/stl/*.h") cmake_files = glob.glob("pybind11/share/cmake/pybind11/*.cmake") pkgconfig_files = glob.glob("pybind11/share/pkgconfig/*.pc") -headers = main_headers + detail_headers + stl_headers + eigen_headers +headers = main_headers + compat_headers + detail_headers + eigen_headers + stl_headers cmdclass = {"install_headers": InstallHeadersNested} $extra_cmd @@ -55,6 +56,7 @@ setup( (base + "share/cmake/pybind11", cmake_files), (base + "share/pkgconfig", pkgconfig_files), (base + "include/pybind11", main_headers), + (base + "include/pybind11/compat", compat_headers), (base + "include/pybind11/detail", detail_headers), (base + "include/pybind11/eigen", eigen_headers), (base + "include/pybind11/stl", stl_headers), diff --git a/tools/setup_main.py.in b/tools/setup_main.py.in index 6358cc7b9b..1eaaa4eab4 100644 --- a/tools/setup_main.py.in +++ b/tools/setup_main.py.in @@ -14,6 +14,7 @@ setup( packages=[ "pybind11", "pybind11.include.pybind11", + "pybind11.include.pybind11.compat", "pybind11.include.pybind11.detail", "pybind11.include.pybind11.eigen", "pybind11.include.pybind11.stl", @@ -23,6 +24,7 @@ setup( package_data={ "pybind11": ["py.typed"], "pybind11.include.pybind11": ["*.h"], + "pybind11.include.pybind11.compat": ["*.h"], "pybind11.include.pybind11.detail": ["*.h"], "pybind11.include.pybind11.eigen": ["*.h"], "pybind11.include.pybind11.stl": ["*.h"], From 4e45a46171374bac0a0e574f0896b6b9a389cadf Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sun, 15 Sep 2024 00:03:54 -0700 Subject: [PATCH 03/13] Factor out pybind11/compat/pybind11_platform_abi_id.h --- CMakeLists.txt | 1 + .../compat/pybind11_platform_abi_id.h | 71 +++++++++++++++++++ include/pybind11/detail/internals.h | 62 +--------------- tests/exo_planet_c_api.cpp | 8 +-- tests/extra_python_package/test_files.py | 1 + 5 files changed, 75 insertions(+), 68 deletions(-) create mode 100644 include/pybind11/compat/pybind11_platform_abi_id.h diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e894e2104..a3b764dfb3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,6 +142,7 @@ set(PYBIND11_HEADERS include/pybind11/cast.h include/pybind11/chrono.h include/pybind11/common.h + include/pybind11/compat/pybind11_platform_abi_id.h include/pybind11/compat/wrap_include_python_h.h include/pybind11/complex.h include/pybind11/options.h diff --git a/include/pybind11/compat/pybind11_platform_abi_id.h b/include/pybind11/compat/pybind11_platform_abi_id.h new file mode 100644 index 0000000000..c02a25f932 --- /dev/null +++ b/include/pybind11/compat/pybind11_platform_abi_id.h @@ -0,0 +1,71 @@ +#pragma once + +// Copyright (c) 2024 The pybind Community. + +#include "wrap_include_python_h.h" + +// Implementation detail. DO NOT USE ELSEWHERE. +// This is duplicated here to maximize portability. +#define PYBIND11_PLATFORM_ABI_ID_STRINGIFY(x) #x +#define PYBIND11_PLATFORM_ABI_ID_TOSTRING(x) PYBIND11_PLATFORM_ABI_ID_STRINGIFY(x) + +// On MSVC, debug and release builds are not ABI-compatible! +#if defined(_MSC_VER) && defined(_DEBUG) +# define PYBIND11_BUILD_TYPE "_debug" +#else +# define PYBIND11_BUILD_TYPE "" +#endif + +// Let's assume that different compilers are ABI-incompatible. +// A user can manually set this string if they know their +// compiler is compatible. +#ifndef PYBIND11_COMPILER_TYPE +# if defined(_MSC_VER) +# define PYBIND11_COMPILER_TYPE "_msvc" +# elif defined(__INTEL_COMPILER) +# define PYBIND11_COMPILER_TYPE "_icc" +# elif defined(__clang__) +# define PYBIND11_COMPILER_TYPE "_clang" +# elif defined(__PGI) +# define PYBIND11_COMPILER_TYPE "_pgi" +# elif defined(__MINGW32__) +# define PYBIND11_COMPILER_TYPE "_mingw" +# elif defined(__CYGWIN__) +# define PYBIND11_COMPILER_TYPE "_gcc_cygwin" +# elif defined(__GNUC__) +# define PYBIND11_COMPILER_TYPE "_gcc" +# else +# define PYBIND11_COMPILER_TYPE "_unknown" +# endif +#endif + +// Also standard libs +#ifndef PYBIND11_STDLIB +# if defined(_LIBCPP_VERSION) +# define PYBIND11_STDLIB "_libcpp" +# elif defined(__GLIBCXX__) || defined(__GLIBCPP__) +# define PYBIND11_STDLIB "_libstdcpp" +# else +# define PYBIND11_STDLIB "" +# endif +#endif + +// On Linux/OSX, changes in __GXX_ABI_VERSION__ indicate ABI incompatibility. +// On MSVC, changes in _MSC_VER may indicate ABI incompatibility (#2898). +#ifndef PYBIND11_BUILD_ABI +# if defined(__GXX_ABI_VERSION) +# define PYBIND11_BUILD_ABI "_cxxabi" PYBIND11_PLATFORM_ABI_ID_TOSTRING(__GXX_ABI_VERSION) +# elif defined(_MSC_VER) +# define PYBIND11_BUILD_ABI "_mscver" PYBIND11_PLATFORM_ABI_ID_TOSTRING(_MSC_VER) +# else +# define PYBIND11_BUILD_ABI "" +# endif +#endif + +#ifndef PYBIND11_INTERNALS_KIND +# define PYBIND11_INTERNALS_KIND "" +#endif + +#define PYBIND11_PLATFORM_ABI_ID \ + PYBIND11_INTERNALS_KIND PYBIND11_COMPILER_TYPE PYBIND11_STDLIB PYBIND11_BUILD_ABI \ + PYBIND11_BUILD_TYPE diff --git a/include/pybind11/detail/internals.h b/include/pybind11/detail/internals.h index 7cc6f53adf..74b8f6a40c 100644 --- a/include/pybind11/detail/internals.h +++ b/include/pybind11/detail/internals.h @@ -15,6 +15,7 @@ # include #endif +#include #include #include @@ -264,67 +265,6 @@ struct type_info { bool module_local : 1; }; -/// On MSVC, debug and release builds are not ABI-compatible! -#if defined(_MSC_VER) && defined(_DEBUG) -# define PYBIND11_BUILD_TYPE "_debug" -#else -# define PYBIND11_BUILD_TYPE "" -#endif - -/// Let's assume that different compilers are ABI-incompatible. -/// A user can manually set this string if they know their -/// compiler is compatible. -#ifndef PYBIND11_COMPILER_TYPE -# if defined(_MSC_VER) -# define PYBIND11_COMPILER_TYPE "_msvc" -# elif defined(__INTEL_COMPILER) -# define PYBIND11_COMPILER_TYPE "_icc" -# elif defined(__clang__) -# define PYBIND11_COMPILER_TYPE "_clang" -# elif defined(__PGI) -# define PYBIND11_COMPILER_TYPE "_pgi" -# elif defined(__MINGW32__) -# define PYBIND11_COMPILER_TYPE "_mingw" -# elif defined(__CYGWIN__) -# define PYBIND11_COMPILER_TYPE "_gcc_cygwin" -# elif defined(__GNUC__) -# define PYBIND11_COMPILER_TYPE "_gcc" -# else -# define PYBIND11_COMPILER_TYPE "_unknown" -# endif -#endif - -/// Also standard libs -#ifndef PYBIND11_STDLIB -# if defined(_LIBCPP_VERSION) -# define PYBIND11_STDLIB "_libcpp" -# elif defined(__GLIBCXX__) || defined(__GLIBCPP__) -# define PYBIND11_STDLIB "_libstdcpp" -# else -# define PYBIND11_STDLIB "" -# endif -#endif - -/// On Linux/OSX, changes in __GXX_ABI_VERSION__ indicate ABI incompatibility. -/// On MSVC, changes in _MSC_VER may indicate ABI incompatibility (#2898). -#ifndef PYBIND11_BUILD_ABI -# if defined(__GXX_ABI_VERSION) -# define PYBIND11_BUILD_ABI "_cxxabi" PYBIND11_TOSTRING(__GXX_ABI_VERSION) -# elif defined(_MSC_VER) -# define PYBIND11_BUILD_ABI "_mscver" PYBIND11_TOSTRING(_MSC_VER) -# else -# define PYBIND11_BUILD_ABI "" -# endif -#endif - -#ifndef PYBIND11_INTERNALS_KIND -# define PYBIND11_INTERNALS_KIND "" -#endif - -#define PYBIND11_PLATFORM_ABI_ID \ - PYBIND11_INTERNALS_KIND PYBIND11_COMPILER_TYPE PYBIND11_STDLIB PYBIND11_BUILD_ABI \ - PYBIND11_BUILD_TYPE - #define PYBIND11_INTERNALS_ID \ "__pybind11_internals_v" PYBIND11_TOSTRING(PYBIND11_INTERNALS_VERSION) \ PYBIND11_PLATFORM_ABI_ID "__" diff --git a/tests/exo_planet_c_api.cpp b/tests/exo_planet_c_api.cpp index 3bde0b27b5..eeaf9cb31e 100644 --- a/tests/exo_planet_c_api.cpp +++ b/tests/exo_planet_c_api.cpp @@ -1,13 +1,7 @@ // Copyright (c) 2024 The pybind Community. // THIS MUST STAY AT THE TOP! -#include // EXCLUSIVELY for PYBIND11_PLATFORM_ABI_ID -// Potential future direction to maximize reusability: -// (e.g. for use from SWIG, Cython, PyCLIF, nanobind): -// #include -// This would only depend on: -// 1. A C++ compiler, WITHOUT requiring -fexceptions. -// 2. Python.h +#include #include "test_cpp_conduit_traveler_types.h" diff --git a/tests/extra_python_package/test_files.py b/tests/extra_python_package/test_files.py index 9f91149888..c657d10857 100644 --- a/tests/extra_python_package/test_files.py +++ b/tests/extra_python_package/test_files.py @@ -51,6 +51,7 @@ } compat_headers = { + "include/pybind11/compat/pybind11_platform_abi_id.h", "include/pybind11/compat/wrap_include_python_h.h", } From 25945a86425936e504c0ed1c58a3e74bceced9c1 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sun, 15 Sep 2024 00:31:58 -0700 Subject: [PATCH 04/13] Add pybind11/compat/README.txt and a couple source code comments. --- include/pybind11/compat/README.txt | 10 ++++++++++ include/pybind11/compat/pybind11_platform_abi_id.h | 3 +++ include/pybind11/compat/wrap_include_python_h.h | 3 +++ 3 files changed, 16 insertions(+) create mode 100644 include/pybind11/compat/README.txt diff --git a/include/pybind11/compat/README.txt b/include/pybind11/compat/README.txt new file mode 100644 index 0000000000..09ddca0bc3 --- /dev/null +++ b/include/pybind11/compat/README.txt @@ -0,0 +1,10 @@ +NOTE +---- + +The C++ code here + +** only depends on ** + +and nothing else. + +DO NOT ADD CODE WITH OTHER EXTERNAL DEPENDENCIES TO THIS DIRECTORY. diff --git a/include/pybind11/compat/pybind11_platform_abi_id.h b/include/pybind11/compat/pybind11_platform_abi_id.h index c02a25f932..f64b9937b1 100644 --- a/include/pybind11/compat/pybind11_platform_abi_id.h +++ b/include/pybind11/compat/pybind11_platform_abi_id.h @@ -2,6 +2,9 @@ // Copyright (c) 2024 The pybind Community. +// To maximize portability: +// DO NOT ADD CODE THAT REQUIRES C++ EXCEPTION HANDLING. + #include "wrap_include_python_h.h" // Implementation detail. DO NOT USE ELSEWHERE. diff --git a/include/pybind11/compat/wrap_include_python_h.h b/include/pybind11/compat/wrap_include_python_h.h index 76bf680bf5..83a4237983 100644 --- a/include/pybind11/compat/wrap_include_python_h.h +++ b/include/pybind11/compat/wrap_include_python_h.h @@ -12,6 +12,9 @@ // the standard headers on some systems, you must include Python.h before // any standard headers are included. +// To maximize portability: +// DO NOT ADD CODE THAT REQUIRES C++ EXCEPTION HANDLING. + // Disable linking to pythonX_d.lib on Windows in debug mode. #if defined(_MSC_VER) && defined(_DEBUG) && !defined(Py_DEBUG) // Workaround for a VS 2022 issue. From b116ec1660eb7330cddb7094de81329e90adc31a Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sun, 15 Sep 2024 10:28:30 -0700 Subject: [PATCH 05/13] Minor changes to comments. --- include/pybind11/compat/pybind11_platform_abi_id.h | 4 ++-- include/pybind11/compat/wrap_include_python_h.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/pybind11/compat/pybind11_platform_abi_id.h b/include/pybind11/compat/pybind11_platform_abi_id.h index f64b9937b1..90b94f0502 100644 --- a/include/pybind11/compat/pybind11_platform_abi_id.h +++ b/include/pybind11/compat/pybind11_platform_abi_id.h @@ -2,12 +2,12 @@ // Copyright (c) 2024 The pybind Community. -// To maximize portability: +// To maximize reusability: // DO NOT ADD CODE THAT REQUIRES C++ EXCEPTION HANDLING. #include "wrap_include_python_h.h" -// Implementation detail. DO NOT USE ELSEWHERE. +// Implementation details. DO NOT USE ELSEWHERE. (Unfortunately we cannot #undef them.) // This is duplicated here to maximize portability. #define PYBIND11_PLATFORM_ABI_ID_STRINGIFY(x) #x #define PYBIND11_PLATFORM_ABI_ID_TOSTRING(x) PYBIND11_PLATFORM_ABI_ID_STRINGIFY(x) diff --git a/include/pybind11/compat/wrap_include_python_h.h b/include/pybind11/compat/wrap_include_python_h.h index 83a4237983..316d1afc84 100644 --- a/include/pybind11/compat/wrap_include_python_h.h +++ b/include/pybind11/compat/wrap_include_python_h.h @@ -12,7 +12,7 @@ // the standard headers on some systems, you must include Python.h before // any standard headers are included. -// To maximize portability: +// To maximize reusability: // DO NOT ADD CODE THAT REQUIRES C++ EXCEPTION HANDLING. // Disable linking to pythonX_d.lib on Windows in debug mode. From c16905706444c25b66131533a385c7e8000fccb5 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sun, 15 Sep 2024 10:56:33 -0700 Subject: [PATCH 06/13] Factor out pybind11/compat/pybind11_conduit_v1.h --- CMakeLists.txt | 1 + include/pybind11/compat/pybind11_conduit_v1.h | 46 ++++++++++++++++++ tests/exo_planet_c_api.cpp | 47 ++----------------- tests/extra_python_package/test_files.py | 1 + 4 files changed, 53 insertions(+), 42 deletions(-) create mode 100644 include/pybind11/compat/pybind11_conduit_v1.h diff --git a/CMakeLists.txt b/CMakeLists.txt index a3b764dfb3..acefc10196 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,6 +142,7 @@ set(PYBIND11_HEADERS include/pybind11/cast.h include/pybind11/chrono.h include/pybind11/common.h + include/pybind11/compat/pybind11_conduit_v1.h include/pybind11/compat/pybind11_platform_abi_id.h include/pybind11/compat/wrap_include_python_h.h include/pybind11/complex.h diff --git a/include/pybind11/compat/pybind11_conduit_v1.h b/include/pybind11/compat/pybind11_conduit_v1.h new file mode 100644 index 0000000000..37e5715a81 --- /dev/null +++ b/include/pybind11/compat/pybind11_conduit_v1.h @@ -0,0 +1,46 @@ +// Copyright (c) 2024 The pybind Community. + +// THIS MUST STAY AT THE TOP! +#include "pybind11_platform_abi_id.h" + +#include +#include + +namespace pybind11_conduit_v1 { + +inline void *get_raw_pointer_ephemeral(PyObject *py_obj, const std::type_info *cpp_type_info) { + PyObject *cpp_type_info_capsule + = PyCapsule_New(const_cast(static_cast(cpp_type_info)), + typeid(std::type_info).name(), + nullptr); + if (cpp_type_info_capsule == nullptr) { + return nullptr; + } + PyObject *cpp_conduit = PyObject_CallMethod(py_obj, + "_pybind11_conduit_v1_", + "yOy", + PYBIND11_PLATFORM_ABI_ID, + cpp_type_info_capsule, + "raw_pointer_ephemeral"); + Py_DECREF(cpp_type_info_capsule); + if (cpp_conduit == nullptr) { + return nullptr; + } + void *raw_ptr = PyCapsule_GetPointer(cpp_conduit, cpp_type_info->name()); + Py_DECREF(cpp_conduit); + if (PyErr_Occurred()) { + return nullptr; + } + return raw_ptr; +} + +template +T *get_type_pointer_ephemeral(PyObject *py_obj) { + void *raw_ptr = get_raw_pointer_ephemeral(py_obj, &typeid(T)); + if (raw_ptr == nullptr) { + return nullptr; + } + return static_cast(raw_ptr); +} + +} // namespace pybind11_conduit_v1 diff --git a/tests/exo_planet_c_api.cpp b/tests/exo_planet_c_api.cpp index eeaf9cb31e..fe51686568 100644 --- a/tests/exo_planet_c_api.cpp +++ b/tests/exo_planet_c_api.cpp @@ -1,53 +1,17 @@ // Copyright (c) 2024 The pybind Community. // THIS MUST STAY AT THE TOP! -#include +#include // VERY light-weight dependency. #include "test_cpp_conduit_traveler_types.h" #include -#include namespace { -void *get_cpp_conduit_void_ptr(PyObject *py_obj, const std::type_info *cpp_type_info) { - PyObject *cpp_type_info_capsule - = PyCapsule_New(const_cast(static_cast(cpp_type_info)), - typeid(std::type_info).name(), - nullptr); - if (cpp_type_info_capsule == nullptr) { - return nullptr; - } - PyObject *cpp_conduit = PyObject_CallMethod(py_obj, - "_pybind11_conduit_v1_", - "yOy", - PYBIND11_PLATFORM_ABI_ID, - cpp_type_info_capsule, - "raw_pointer_ephemeral"); - Py_DECREF(cpp_type_info_capsule); - if (cpp_conduit == nullptr) { - return nullptr; - } - void *void_ptr = PyCapsule_GetPointer(cpp_conduit, cpp_type_info->name()); - Py_DECREF(cpp_conduit); - if (PyErr_Occurred()) { - return nullptr; - } - return void_ptr; -} - -template -T *get_cpp_conduit_type_ptr(PyObject *py_obj) { - void *void_ptr = get_cpp_conduit_void_ptr(py_obj, &typeid(T)); - if (void_ptr == nullptr) { - return nullptr; - } - return static_cast(void_ptr); -} - extern "C" PyObject *wrapGetLuggage(PyObject * /*self*/, PyObject *traveler) { - const auto *cpp_traveler - = get_cpp_conduit_type_ptr(traveler); + const auto *cpp_traveler = pybind11_conduit_v1::get_type_pointer_ephemeral< + pybind11_tests::test_cpp_conduit::Traveler>(traveler); if (cpp_traveler == nullptr) { return nullptr; } @@ -55,9 +19,8 @@ extern "C" PyObject *wrapGetLuggage(PyObject * /*self*/, PyObject *traveler) { } extern "C" PyObject *wrapGetPoints(PyObject * /*self*/, PyObject *premium_traveler) { - const auto *cpp_premium_traveler - = get_cpp_conduit_type_ptr( - premium_traveler); + const auto *cpp_premium_traveler = pybind11_conduit_v1::get_type_pointer_ephemeral< + pybind11_tests::test_cpp_conduit::PremiumTraveler>(premium_traveler); if (cpp_premium_traveler == nullptr) { return nullptr; } diff --git a/tests/extra_python_package/test_files.py b/tests/extra_python_package/test_files.py index c657d10857..5f9c880533 100644 --- a/tests/extra_python_package/test_files.py +++ b/tests/extra_python_package/test_files.py @@ -51,6 +51,7 @@ } compat_headers = { + "include/pybind11/compat/pybind11_conduit_v1.h", "include/pybind11/compat/pybind11_platform_abi_id.h", "include/pybind11/compat/wrap_include_python_h.h", } From 9aabe52e44685aa72cd14b40b967b157a8ef47ad Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sun, 15 Sep 2024 11:28:00 -0700 Subject: [PATCH 07/13] Add long comment to pybind11/compat/pybind11_conduit_v1.h --- include/pybind11/compat/README.txt | 5 ++ include/pybind11/compat/pybind11_conduit_v1.h | 65 +++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/include/pybind11/compat/README.txt b/include/pybind11/compat/README.txt index 09ddca0bc3..9a2c53ba42 100644 --- a/include/pybind11/compat/README.txt +++ b/include/pybind11/compat/README.txt @@ -8,3 +8,8 @@ The C++ code here and nothing else. DO NOT ADD CODE WITH OTHER EXTERNAL DEPENDENCIES TO THIS DIRECTORY. + +Read on: + +pybind11_conduit_v1.h — Type-safe interoperability between different + independent Python/C++ bindings systems. diff --git a/include/pybind11/compat/pybind11_conduit_v1.h b/include/pybind11/compat/pybind11_conduit_v1.h index 37e5715a81..e3a4534535 100644 --- a/include/pybind11/compat/pybind11_conduit_v1.h +++ b/include/pybind11/compat/pybind11_conduit_v1.h @@ -1,5 +1,70 @@ // Copyright (c) 2024 The pybind Community. +/* The pybind11_conduit_v1 feature enables type-safe interoperability between + +* different independent Python/C++ bindings systems, + +* including pybind11 versions with different PYBIND11_INTERNALS_VERSION's. + +The naming of the feature is a bit misleading: + +* The feature is in no way tied to pybind11 internals. + +* It just happens to originate from pybind11 and currently still lives there. + +* The only external dependency is . + +The implementation is a VERY light-weight dependency. It is designed to be +compatible with any ISO C++11 (or higher) compiler, and does NOT require +C++ Exception Handling to be enabled. + +Please see https://github.com/pybind/pybind11/pull/5296 for more background. + +The implementation involves a + +def _pybind11_conduit_v1_( + self, + pybind11_platform_abi_id: bytes, + cpp_type_info_capsule: capsule, + pointer_kind: bytes) -> capsule + +method that is meant to be added to Python objects wrapping C++ objects +(e.g. pybind11::class_-wrapped types). + +The design of the _pybind11_conduit_v1_ feature provides two layers of +protection against C++ ABI mismatches: + +* The first and most important layer is that the pybind11_platform_abi_id's + must match between extensions. — This will never be perfect, but is the same + pragmatic approach used in pybind11 since 2017 + (https://github.com/pybind/pybind11/commit/96997a4b9d4ec3d389a570604394af5d5eee2557, + PYBIND11_INTERNALS_ID). + +* The second layer is that the typeid(std::type_info).name()'s must match + between extensions. + +The implementation below (which is shorter than this comment!), serves as a +battle-tested specification. The main API is this one function: + +auto *cpp_pointer = pybind11_conduit_v1::get_type_pointer_ephemeral(py_obj); + +It is meant to be a minimalistic reference implementation, intentionally +without comprehensive error reporting. It is expected that major bindings +systems will roll their own, compatible implementations, potentially with +system-specific error reporting. The essential specifications all bindings +systems need to agree on are merely: + +* PYBIND11_PLATFORM_ABI_ID (const char* literal). + +* The cpp_type_info capsule (see below: a void *ptr and a const char *name). + +* The cpp_conduit capsule (see below: a void *ptr and a const char *name). + +* "raw_pointer_ephemeral" means: the lifetime of the pointer is the lifetime + of the py_obj. + +*/ + // THIS MUST STAY AT THE TOP! #include "pybind11_platform_abi_id.h" From a0eb9f398d9b91283eb964b7dc29aab24289a7af Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sun, 15 Sep 2024 12:44:39 -0700 Subject: [PATCH 08/13] Add pybind11/compat/README.txt to wheels. --- tests/extra_python_package/test_files.py | 1 + tools/setup_global.py.in | 3 ++- tools/setup_main.py.in | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/extra_python_package/test_files.py b/tests/extra_python_package/test_files.py index 5f9c880533..d926c9fe33 100644 --- a/tests/extra_python_package/test_files.py +++ b/tests/extra_python_package/test_files.py @@ -51,6 +51,7 @@ } compat_headers = { + "include/pybind11/compat/README.txt", "include/pybind11/compat/pybind11_conduit_v1.h", "include/pybind11/compat/pybind11_platform_abi_id.h", "include/pybind11/compat/wrap_include_python_h.h", diff --git a/tools/setup_global.py.in b/tools/setup_global.py.in index 7d22a71e18..2c88c7dea8 100644 --- a/tools/setup_global.py.in +++ b/tools/setup_global.py.in @@ -26,7 +26,8 @@ class InstallHeadersNested(install_headers): main_headers = glob.glob("pybind11/include/pybind11/*.h") -compat_headers = glob.glob("pybind11/include/pybind11/compat/*.h") +compat_headers = sum([glob.glob(f"pybind11/include/pybind11/compat/*.{ext}") + for ext in ("h", "txt")], []) detail_headers = glob.glob("pybind11/include/pybind11/detail/*.h") eigen_headers = glob.glob("pybind11/include/pybind11/eigen/*.h") stl_headers = glob.glob("pybind11/include/pybind11/stl/*.h") diff --git a/tools/setup_main.py.in b/tools/setup_main.py.in index 1eaaa4eab4..446812947b 100644 --- a/tools/setup_main.py.in +++ b/tools/setup_main.py.in @@ -24,7 +24,7 @@ setup( package_data={ "pybind11": ["py.typed"], "pybind11.include.pybind11": ["*.h"], - "pybind11.include.pybind11.compat": ["*.h"], + "pybind11.include.pybind11.compat": ["*.h", "*.txt"], "pybind11.include.pybind11.detail": ["*.h"], "pybind11.include.pybind11.eigen": ["*.h"], "pybind11.include.pybind11.stl": ["*.h"], From 75871ef1716e6f420de761fc78304d57e544983a Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Mon, 16 Sep 2024 07:55:03 -0700 Subject: [PATCH 09/13] Add `-fno-exceptions` to compiler options for exo_planet_c_api --- tests/CMakeLists.txt | 6 ++++++ tests/exo_planet_c_api.cpp | 7 +++++++ 2 files changed, 13 insertions(+) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 03ff39138d..c99cd4084b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -493,6 +493,12 @@ foreach(target ${test_targets}) endif() endforeach() +if(MSVC) + target_compile_options("exo_planet_c_api" PRIVATE /EHs-c-) +elseif(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Intel|Clang)") + target_compile_options("exo_planet_c_api" PRIVATE -fno-exceptions) +endif() + # Provide nice organisation in IDEs source_group( TREE "${CMAKE_CURRENT_SOURCE_DIR}/../include" diff --git a/tests/exo_planet_c_api.cpp b/tests/exo_planet_c_api.cpp index fe51686568..8dc574a22e 100644 --- a/tests/exo_planet_c_api.cpp +++ b/tests/exo_planet_c_api.cpp @@ -1,5 +1,12 @@ // Copyright (c) 2024 The pybind Community. +#ifdef __EXCEPTIONS +# error This test is meant to be built with C++ Exception Handling disabled. +// In production situations it is totally fine to build with +// C++ Exception Handling enabled. Here we just want to ensure that +// C++ Exception Handling is not required. +#endif + // THIS MUST STAY AT THE TOP! #include // VERY light-weight dependency. From 1b2883744356d68b556f05060dee9fa269fe0ce0 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Mon, 16 Sep 2024 13:14:48 -0700 Subject: [PATCH 10/13] 1. Move `target_compile_options()` into loop over test targets, in case the `"exo_planet_c_api"` target does not exist. 2. Add `-fno-exceptions` option also for `NVHPC`. 3. Also check for `__cpp_exceptions` in exo_planet_c_api.cpp. --- tests/CMakeLists.txt | 14 ++++++++------ tests/exo_planet_c_api.cpp | 11 ++++++++--- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index c99cd4084b..3c9b063f77 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -491,13 +491,15 @@ foreach(target ${test_targets}) if(SKBUILD) install(TARGETS ${target} LIBRARY DESTINATION .) endif() -endforeach() -if(MSVC) - target_compile_options("exo_planet_c_api" PRIVATE /EHs-c-) -elseif(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Intel|Clang)") - target_compile_options("exo_planet_c_api" PRIVATE -fno-exceptions) -endif() + if("${target}" STREQUAL "exo_planet_c_api") + if(MSVC) + target_compile_options(${target} PRIVATE /EHs-c-) + elseif(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Intel|Clang|NVHPC)") + target_compile_options(${target} PRIVATE -fno-exceptions) + endif() + endif() +endforeach() # Provide nice organisation in IDEs source_group( diff --git a/tests/exo_planet_c_api.cpp b/tests/exo_planet_c_api.cpp index 8dc574a22e..cf584c35f6 100644 --- a/tests/exo_planet_c_api.cpp +++ b/tests/exo_planet_c_api.cpp @@ -1,10 +1,15 @@ // Copyright (c) 2024 The pybind Community. -#ifdef __EXCEPTIONS -# error This test is meant to be built with C++ Exception Handling disabled. // In production situations it is totally fine to build with -// C++ Exception Handling enabled. Here we just want to ensure that +// C++ Exception Handling enabled. However, here we want to ensure that // C++ Exception Handling is not required. +#ifdef __cpp_exceptions +// https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations#__cpp_exceptions +# error This test is meant to be built with C++ Exception Handling disabled, but __cpp_exceptions is defined. +#endif +#ifndef __EXCEPTIONS +// https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html +# error This test is meant to be built with C++ Exception Handling disabled, but __EXCEPTIONS is defined. #endif // THIS MUST STAY AT THE TOP! From d1527e390f658d88b0f01d8846ae1cb108206841 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Mon, 16 Sep 2024 13:25:35 -0700 Subject: [PATCH 11/13] 1. Fix accident (forgot to undo temporary change). 2. Special-case __EMSCRIPTEN__ in exo_planet_c_api.cpp --- tests/exo_planet_c_api.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/exo_planet_c_api.cpp b/tests/exo_planet_c_api.cpp index cf584c35f6..9e85a32808 100644 --- a/tests/exo_planet_c_api.cpp +++ b/tests/exo_planet_c_api.cpp @@ -3,13 +3,17 @@ // In production situations it is totally fine to build with // C++ Exception Handling enabled. However, here we want to ensure that // C++ Exception Handling is not required. -#ifdef __cpp_exceptions +#ifdef __EMSCRIPTEN__ +// Too much trouble making the required cmake changes. +#else +# ifdef __cpp_exceptions // https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations#__cpp_exceptions # error This test is meant to be built with C++ Exception Handling disabled, but __cpp_exceptions is defined. -#endif -#ifndef __EXCEPTIONS +# endif +# ifdef __EXCEPTIONS // https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html # error This test is meant to be built with C++ Exception Handling disabled, but __EXCEPTIONS is defined. +# endif #endif // THIS MUST STAY AT THE TOP! From 6cb1d65e77693fd0aa45327c4b0bb067ed3ac3d5 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Mon, 16 Sep 2024 15:30:49 -0700 Subject: [PATCH 12/13] Give up on compiling exo_planet_c_api.cpp with MSVC `/EHs-c-`: There was one trouble maker (all other jobs worked): Visual Studio 15 2017: ``` cl : Command line warning D9025: overriding '/EHc' with '/EHc-' [C:\projects\pybind11\tests\exo_planet_c_api.vcxproj] ... C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\xlocale(319): error C2220: warning treated as error - no 'object' file generated [C:\projects\pybind11\tests\exo_planet_c_api.vcxproj] C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\include\xlocale(319): warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc ``` --- tests/CMakeLists.txt | 4 +--- tests/exo_planet_c_api.cpp | 4 ++-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 3c9b063f77..01b6c0a3e6 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -493,9 +493,7 @@ foreach(target ${test_targets}) endif() if("${target}" STREQUAL "exo_planet_c_api") - if(MSVC) - target_compile_options(${target} PRIVATE /EHs-c-) - elseif(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Intel|Clang|NVHPC)") + if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Intel|Clang|NVHPC)") target_compile_options(${target} PRIVATE -fno-exceptions) endif() endif() diff --git a/tests/exo_planet_c_api.cpp b/tests/exo_planet_c_api.cpp index 9e85a32808..d37d6bb8fc 100644 --- a/tests/exo_planet_c_api.cpp +++ b/tests/exo_planet_c_api.cpp @@ -3,8 +3,8 @@ // In production situations it is totally fine to build with // C++ Exception Handling enabled. However, here we want to ensure that // C++ Exception Handling is not required. -#ifdef __EMSCRIPTEN__ -// Too much trouble making the required cmake changes. +#if defined(_MSC_VER) || defined(__EMSCRIPTEN__) +// Too much trouble making the required cmake changes (see PR #5375). #else # ifdef __cpp_exceptions // https://isocpp.org/std/standing-documents/sd-6-sg10-feature-test-recommendations#__cpp_exceptions From bbca3b46fc367da8527893cd97807d7300c57bb1 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Sun, 10 Nov 2024 10:58:00 -0800 Subject: [PATCH 13/13] Move pybind11/compat to pybind11/conduit as suggested by @henryiii: https://github.com/pybind/pybind11/pull/5375#pullrequestreview-2329006001 --- CMakeLists.txt | 6 +++--- include/pybind11/{compat => conduit}/README.txt | 0 .../{compat => conduit}/pybind11_conduit_v1.h | 0 .../{compat => conduit}/pybind11_platform_abi_id.h | 0 .../{compat => conduit}/wrap_include_python_h.h | 0 include/pybind11/detail/common.h | 2 +- include/pybind11/detail/internals.h | 2 +- tests/exo_planet_c_api.cpp | 2 +- tests/extra_python_package/test_files.py | 14 +++++++------- tools/setup_global.py.in | 8 ++++---- tools/setup_main.py.in | 4 ++-- 11 files changed, 19 insertions(+), 19 deletions(-) rename include/pybind11/{compat => conduit}/README.txt (100%) rename include/pybind11/{compat => conduit}/pybind11_conduit_v1.h (100%) rename include/pybind11/{compat => conduit}/pybind11_platform_abi_id.h (100%) rename include/pybind11/{compat => conduit}/wrap_include_python_h.h (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index acefc10196..9357f31fbd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,10 +142,10 @@ set(PYBIND11_HEADERS include/pybind11/cast.h include/pybind11/chrono.h include/pybind11/common.h - include/pybind11/compat/pybind11_conduit_v1.h - include/pybind11/compat/pybind11_platform_abi_id.h - include/pybind11/compat/wrap_include_python_h.h include/pybind11/complex.h + include/pybind11/conduit/pybind11_conduit_v1.h + include/pybind11/conduit/pybind11_platform_abi_id.h + include/pybind11/conduit/wrap_include_python_h.h include/pybind11/options.h include/pybind11/eigen.h include/pybind11/eigen/common.h diff --git a/include/pybind11/compat/README.txt b/include/pybind11/conduit/README.txt similarity index 100% rename from include/pybind11/compat/README.txt rename to include/pybind11/conduit/README.txt diff --git a/include/pybind11/compat/pybind11_conduit_v1.h b/include/pybind11/conduit/pybind11_conduit_v1.h similarity index 100% rename from include/pybind11/compat/pybind11_conduit_v1.h rename to include/pybind11/conduit/pybind11_conduit_v1.h diff --git a/include/pybind11/compat/pybind11_platform_abi_id.h b/include/pybind11/conduit/pybind11_platform_abi_id.h similarity index 100% rename from include/pybind11/compat/pybind11_platform_abi_id.h rename to include/pybind11/conduit/pybind11_platform_abi_id.h diff --git a/include/pybind11/compat/wrap_include_python_h.h b/include/pybind11/conduit/wrap_include_python_h.h similarity index 100% rename from include/pybind11/compat/wrap_include_python_h.h rename to include/pybind11/conduit/wrap_include_python_h.h diff --git a/include/pybind11/detail/common.h b/include/pybind11/detail/common.h index 2f97279158..310c3c3947 100644 --- a/include/pybind11/detail/common.h +++ b/include/pybind11/detail/common.h @@ -9,7 +9,7 @@ #pragma once -#include +#include #if PY_VERSION_HEX < 0x03080000 # error "PYTHON < 3.8 IS UNSUPPORTED. pybind11 v2.13 was the last to support Python 3.7." #endif diff --git a/include/pybind11/detail/internals.h b/include/pybind11/detail/internals.h index bb101a725a..278f35bbaa 100644 --- a/include/pybind11/detail/internals.h +++ b/include/pybind11/detail/internals.h @@ -15,7 +15,7 @@ # include #endif -#include +#include #include #include diff --git a/tests/exo_planet_c_api.cpp b/tests/exo_planet_c_api.cpp index d37d6bb8fc..1510107175 100644 --- a/tests/exo_planet_c_api.cpp +++ b/tests/exo_planet_c_api.cpp @@ -17,7 +17,7 @@ #endif // THIS MUST STAY AT THE TOP! -#include // VERY light-weight dependency. +#include // VERY light-weight dependency. #include "test_cpp_conduit_traveler_types.h" diff --git a/tests/extra_python_package/test_files.py b/tests/extra_python_package/test_files.py index d926c9fe33..977db75c63 100644 --- a/tests/extra_python_package/test_files.py +++ b/tests/extra_python_package/test_files.py @@ -50,11 +50,11 @@ "include/pybind11/warnings.h", } -compat_headers = { - "include/pybind11/compat/README.txt", - "include/pybind11/compat/pybind11_conduit_v1.h", - "include/pybind11/compat/pybind11_platform_abi_id.h", - "include/pybind11/compat/wrap_include_python_h.h", +conduit_headers = { + "include/pybind11/conduit/README.txt", + "include/pybind11/conduit/pybind11_conduit_v1.h", + "include/pybind11/conduit/pybind11_platform_abi_id.h", + "include/pybind11/conduit/wrap_include_python_h.h", } detail_headers = { @@ -104,7 +104,7 @@ "setup_helpers.py", } -headers = main_headers | compat_headers | detail_headers | eigen_headers | stl_headers +headers = main_headers | conduit_headers | detail_headers | eigen_headers | stl_headers src_files = headers | cmake_files | pkgconfig_files all_files = src_files | py_files @@ -113,7 +113,7 @@ "pybind11", "pybind11/include", "pybind11/include/pybind11", - "pybind11/include/pybind11/compat", + "pybind11/include/pybind11/conduit", "pybind11/include/pybind11/detail", "pybind11/include/pybind11/eigen", "pybind11/include/pybind11/stl", diff --git a/tools/setup_global.py.in b/tools/setup_global.py.in index 2c88c7dea8..99b8a2b29e 100644 --- a/tools/setup_global.py.in +++ b/tools/setup_global.py.in @@ -26,14 +26,14 @@ class InstallHeadersNested(install_headers): main_headers = glob.glob("pybind11/include/pybind11/*.h") -compat_headers = sum([glob.glob(f"pybind11/include/pybind11/compat/*.{ext}") - for ext in ("h", "txt")], []) +conduit_headers = sum([glob.glob(f"pybind11/include/pybind11/conduit/*.{ext}") + for ext in ("h", "txt")], []) detail_headers = glob.glob("pybind11/include/pybind11/detail/*.h") eigen_headers = glob.glob("pybind11/include/pybind11/eigen/*.h") stl_headers = glob.glob("pybind11/include/pybind11/stl/*.h") cmake_files = glob.glob("pybind11/share/cmake/pybind11/*.cmake") pkgconfig_files = glob.glob("pybind11/share/pkgconfig/*.pc") -headers = main_headers + compat_headers + detail_headers + eigen_headers + stl_headers +headers = main_headers + conduit_headers + detail_headers + eigen_headers + stl_headers cmdclass = {"install_headers": InstallHeadersNested} $extra_cmd @@ -57,7 +57,7 @@ setup( (base + "share/cmake/pybind11", cmake_files), (base + "share/pkgconfig", pkgconfig_files), (base + "include/pybind11", main_headers), - (base + "include/pybind11/compat", compat_headers), + (base + "include/pybind11/conduit", conduit_headers), (base + "include/pybind11/detail", detail_headers), (base + "include/pybind11/eigen", eigen_headers), (base + "include/pybind11/stl", stl_headers), diff --git a/tools/setup_main.py.in b/tools/setup_main.py.in index 446812947b..eb7b84ed6a 100644 --- a/tools/setup_main.py.in +++ b/tools/setup_main.py.in @@ -14,7 +14,7 @@ setup( packages=[ "pybind11", "pybind11.include.pybind11", - "pybind11.include.pybind11.compat", + "pybind11.include.pybind11.conduit", "pybind11.include.pybind11.detail", "pybind11.include.pybind11.eigen", "pybind11.include.pybind11.stl", @@ -24,7 +24,7 @@ setup( package_data={ "pybind11": ["py.typed"], "pybind11.include.pybind11": ["*.h"], - "pybind11.include.pybind11.compat": ["*.h", "*.txt"], + "pybind11.include.pybind11.conduit": ["*.h", "*.txt"], "pybind11.include.pybind11.detail": ["*.h"], "pybind11.include.pybind11.eigen": ["*.h"], "pybind11.include.pybind11.stl": ["*.h"],