mirror of https://github.com/pybind/pybind11.git
Factor out pybind11/compat/wrap_include_python_h.h
This commit is contained in:
parent
0cf3a0f7b5
commit
d26ad7ba11
|
@ -142,6 +142,7 @@ set(PYBIND11_HEADERS
|
||||||
include/pybind11/cast.h
|
include/pybind11/cast.h
|
||||||
include/pybind11/chrono.h
|
include/pybind11/chrono.h
|
||||||
include/pybind11/common.h
|
include/pybind11/common.h
|
||||||
|
include/pybind11/compat/wrap_include_python_h.h
|
||||||
include/pybind11/complex.h
|
include/pybind11/complex.h
|
||||||
include/pybind11/options.h
|
include/pybind11/options.h
|
||||||
include/pybind11/eigen.h
|
include/pybind11/eigen.h
|
||||||
|
|
|
@ -0,0 +1,69 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
// Copyright (c) 2024 The pybind Community.
|
||||||
|
|
||||||
|
// STRONG REQUIREMENT:
|
||||||
|
// This header is a wrapper around `#include <Python.h>`, 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 <yvals.h>
|
||||||
|
# if _MSVC_STL_VERSION >= 143
|
||||||
|
# include <crtdefs.h>
|
||||||
|
# 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 <Python.h>
|
||||||
|
#include <frameobject.h>
|
||||||
|
#include <pythread.h>
|
||||||
|
|
||||||
|
#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
|
|
@ -9,6 +9,11 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <pybind11/compat/wrap_include_python_h.h>
|
||||||
|
#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_MAJOR 2
|
||||||
#define PYBIND11_VERSION_MINOR 14
|
#define PYBIND11_VERSION_MINOR 14
|
||||||
#define PYBIND11_VERSION_PATCH 0.dev1
|
#define PYBIND11_VERSION_PATCH 0.dev1
|
||||||
|
@ -212,31 +217,6 @@
|
||||||
# define PYBIND11_MAYBE_UNUSED __attribute__((__unused__))
|
# define PYBIND11_MAYBE_UNUSED __attribute__((__unused__))
|
||||||
#endif
|
#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 <yvals.h>
|
|
||||||
# if _MSVC_STL_VERSION >= 143
|
|
||||||
# include <crtdefs.h>
|
|
||||||
# endif
|
|
||||||
# define PYBIND11_DEBUG_MARKER
|
|
||||||
# undef _DEBUG
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// https://en.cppreference.com/w/c/chrono/localtime
|
// https://en.cppreference.com/w/c/chrono/localtime
|
||||||
#if defined(__STDC_LIB_EXT1__) && !defined(__STDC_WANT_LIB_EXT1__)
|
#if defined(__STDC_LIB_EXT1__) && !defined(__STDC_WANT_LIB_EXT1__)
|
||||||
# define __STDC_WANT_LIB_EXT1__
|
# define __STDC_WANT_LIB_EXT1__
|
||||||
|
@ -271,30 +251,6 @@ PYBIND11_WARNING_DISABLE_MSVC(4505)
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <Python.h>
|
|
||||||
#if PY_VERSION_HEX < 0x03080000
|
|
||||||
# error "PYTHON < 3.8 IS UNSUPPORTED. pybind11 v2.13 was the last to support Python 3.7."
|
|
||||||
#endif
|
|
||||||
#include <frameobject.h>
|
|
||||||
#include <pythread.h>
|
|
||||||
|
|
||||||
/* 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)
|
#if defined(PYBIND11_NUMPY_1_ONLY)
|
||||||
# define PYBIND11_INTERNAL_NUMPY_1_ONLY_DETECTED
|
# define PYBIND11_INTERNAL_NUMPY_1_ONLY_DETECTED
|
||||||
#endif
|
#endif
|
||||||
|
@ -303,14 +259,6 @@ PYBIND11_WARNING_DISABLE_MSVC(4505)
|
||||||
# define PYBIND11_SIMPLE_GIL_MANAGEMENT
|
# define PYBIND11_SIMPLE_GIL_MANAGEMENT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
|
||||||
# if defined(PYBIND11_DEBUG_MARKER)
|
|
||||||
# define _DEBUG
|
|
||||||
# undef PYBIND11_DEBUG_MARKER
|
|
||||||
# endif
|
|
||||||
PYBIND11_WARNING_POP
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
|
|
@ -50,6 +50,10 @@ main_headers = {
|
||||||
"include/pybind11/warnings.h",
|
"include/pybind11/warnings.h",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compat_headers = {
|
||||||
|
"include/pybind11/compat/wrap_include_python_h.h",
|
||||||
|
}
|
||||||
|
|
||||||
detail_headers = {
|
detail_headers = {
|
||||||
"include/pybind11/detail/class.h",
|
"include/pybind11/detail/class.h",
|
||||||
"include/pybind11/detail/common.h",
|
"include/pybind11/detail/common.h",
|
||||||
|
@ -97,7 +101,7 @@ py_files = {
|
||||||
"setup_helpers.py",
|
"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
|
src_files = headers | cmake_files | pkgconfig_files
|
||||||
all_files = src_files | py_files
|
all_files = src_files | py_files
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue