mirror of
https://github.com/pybind/pybind11.git
synced 2026-05-14 02:03:34 +00:00
fix: allow subinterp support to be disabled
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
This commit is contained in:
committed by
Henry Schreiner
parent
33fb53335e
commit
e4873e8f59
@@ -256,9 +256,13 @@
|
||||
|
||||
// Slightly faster code paths are available when PYBIND11_HAS_SUBINTERPRETER_SUPPORT is *not*
|
||||
// defined, so avoid defining it for implementations that do not support subinterpreters. However,
|
||||
// defining it unnecessarily is not expected to break anything.
|
||||
#if PY_VERSION_HEX >= 0x030C0000 && !defined(PYPY_VERSION) && !defined(GRAALVM_PYTHON)
|
||||
# define PYBIND11_HAS_SUBINTERPRETER_SUPPORT
|
||||
// defining it unnecessarily is not expected to break anything (other than old iOS targets).
|
||||
#ifndef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
|
||||
# if PY_VERSION_HEX >= 0x030C0000 && !defined(PYPY_VERSION) && !defined(GRAALVM_PYTHON)
|
||||
# define PYBIND11_HAS_SUBINTERPRETER_SUPPORT 1
|
||||
# else
|
||||
# define PYBIND11_HAS_SUBINTERPRETER_SUPPORT 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// 3.12 Compatibility
|
||||
|
||||
@@ -324,7 +324,7 @@ inline std::atomic<int> &get_num_interpreters_seen() {
|
||||
|
||||
template <typename InternalsType>
|
||||
inline std::unique_ptr<InternalsType> *&get_internals_pp() {
|
||||
#ifdef PYBIND11_HAS_SUBINTERPRETER_SUPPORT
|
||||
#if PYBIND11_HAS_SUBINTERPRETER_SUPPORT
|
||||
if (get_num_interpreters_seen() > 1) {
|
||||
// Internals is one per interpreter. When multiple interpreters are alive in different
|
||||
// threads we have to allow them to have different internals, so we need a thread_local.
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#if !defined(PYBIND11_HAS_SUBINTERPRETER_SUPPORT)
|
||||
#if !PYBIND11_HAS_SUBINTERPRETER_SUPPORT
|
||||
# error "This platform does not support subinterpreters, do not include this file."
|
||||
#endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user