Skip to content

Commit 5b568e8

Browse files
committed
fix: allow subinterp support to be disabled
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 22a4214 commit 5b568e8

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

include/pybind11/detail/common.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,13 @@
256256

257257
// Slightly faster code paths are available when PYBIND11_HAS_SUBINTERPRETER_SUPPORT is *not*
258258
// defined, so avoid defining it for implementations that do not support subinterpreters. However,
259-
// defining it unnecessarily is not expected to break anything.
260-
#if PY_VERSION_HEX >= 0x030C0000 && !defined(PYPY_VERSION) && !defined(GRAALVM_PYTHON)
261-
# define PYBIND11_HAS_SUBINTERPRETER_SUPPORT
259+
// defining it unnecessarily is not expected to break anything (other than old iOS targets).
260+
#ifndef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
261+
# if PY_VERSION_HEX >= 0x030C0000 && !defined(PYPY_VERSION) && !defined(GRAALVM_PYTHON)
262+
# define PYBIND11_HAS_SUBINTERPRETER_SUPPORT 1
263+
# else
264+
# define PYBIND11_HAS_SUBINTERPRETER_SUPPORT 0
265+
# endif
262266
#endif
263267

264268
// 3.12 Compatibility

include/pybind11/subinterpreter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
#include <stdexcept>
1717

18-
#if !defined(PYBIND11_HAS_SUBINTERPRETER_SUPPORT)
18+
#if !PYBIND11_HAS_SUBINTERPRETER_SUPPORT
1919
# error "This platform does not support subinterpreters, do not include this file."
2020
#endif
2121

tests/pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ build.verbose = true
1515

1616
[tool.scikit-build.cmake.define]
1717
PYBIND11_FINDPYTHON = true
18+
CMAKE_COLOR_DIAGNOSTICS = "1"
1819

1920
[tool.cibuildwheel]
2021
test-sources = ["tests", "pyproject.toml"]
@@ -24,3 +25,4 @@ environment.PIP_PREFER_BINARY = "1"
2425
ios.environment.IPHONEOS_DEPLOYMENT_TARGET = "17.0"
2526
ios.xbuild-tools = ["cmake", "ninja"]
2627
ios.environment.PIP_EXTRA_INDEX_URL = "https://pypi.anaconda.org/beeware/simple"
28+
ios.config-settings."cmake.define.CMAKE_CXX_FLAGS" = "-DPYBIND11_HAS_SUBINTERPRETER_SUPPORT=0"

tests/test_embed/test_subinterpreter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include <pybind11/embed.h>
2-
#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
2+
#if PYBIND11_HAS_SUBINTERPRETER_SUPPORT
33
# include <pybind11/subinterpreter.h>
44

55
// Silence MSVC C++17 deprecation warning from Catch regarding std::uncaught_exceptions (up to

0 commit comments

Comments
 (0)