netgen-mesher 6.2.2504.post11.dev0__cp313-cp313-win_amd64.whl → 6.2.2506.post48.dev0__cp313-cp313-win_amd64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (153) hide show
  1. netgen/__init__.pyi +3 -3
  2. netgen/cmake/NetgenConfig.cmake +10 -9
  3. netgen/config/__init__.pyi +8 -8
  4. netgen/config/config.py +7 -7
  5. netgen/config/config.pyi +8 -8
  6. netgen/include/core/archive.hpp +18 -3
  7. netgen/include/core/array.hpp +20 -4
  8. netgen/include/core/autodiff.hpp +9 -11
  9. netgen/include/core/autodiffdiff.hpp +0 -2
  10. netgen/include/core/bitarray.hpp +1 -1
  11. netgen/include/core/flags.hpp +1 -1
  12. netgen/include/core/hashtable.hpp +1 -1
  13. netgen/include/core/memtracer.hpp +7 -7
  14. netgen/include/core/ngcore.hpp +5 -0
  15. netgen/include/core/ngcore_api.hpp +11 -0
  16. netgen/include/core/paje_trace.hpp +9 -8
  17. netgen/include/core/profiler.hpp +5 -5
  18. netgen/include/core/register_archive.hpp +8 -0
  19. netgen/include/core/simd.hpp +69 -1
  20. netgen/include/core/simd_arm64.hpp +205 -1
  21. netgen/include/core/simd_avx.hpp +72 -4
  22. netgen/include/core/simd_avx512.hpp +9 -0
  23. netgen/include/core/simd_generic.hpp +274 -8
  24. netgen/include/core/simd_math.hpp +178 -0
  25. netgen/include/core/simd_sse.hpp +11 -1
  26. netgen/include/core/statushandler.hpp +37 -0
  27. netgen/include/core/table.hpp +3 -2
  28. netgen/include/core/taskmanager.hpp +34 -1
  29. netgen/include/core/utils.hpp +3 -8
  30. netgen/include/include/netgen_version.hpp +4 -4
  31. netgen/include/meshing/basegeom.hpp +1 -4
  32. netgen/include/meshing/global.hpp +0 -17
  33. netgen/include/meshing/hpref_tet.hpp +41 -0
  34. netgen/include/meshing/hprefinement.hpp +2 -0
  35. netgen/include/meshing/meshtype.hpp +2 -1
  36. netgen/include/meshing/msghandler.hpp +9 -6
  37. netgen/include/meshing/topology.hpp +2 -2
  38. netgen/include/nginterface.h +3 -2
  39. netgen/include/occ/occ_utils.hpp +26 -0
  40. netgen/include/occ/occgeom.hpp +8 -0
  41. netgen/include/pybind11/attr.h +40 -8
  42. netgen/include/pybind11/buffer_info.h +14 -14
  43. netgen/include/pybind11/cast.h +553 -29
  44. netgen/include/pybind11/chrono.h +4 -1
  45. netgen/include/pybind11/conduit/README.txt +15 -0
  46. netgen/include/pybind11/conduit/pybind11_conduit_v1.h +116 -0
  47. netgen/include/pybind11/conduit/pybind11_platform_abi_id.h +87 -0
  48. netgen/include/pybind11/conduit/wrap_include_python_h.h +72 -0
  49. netgen/include/pybind11/critical_section.h +56 -0
  50. netgen/include/pybind11/detail/class.h +172 -97
  51. netgen/include/pybind11/detail/common.h +270 -189
  52. netgen/include/pybind11/detail/cpp_conduit.h +75 -0
  53. netgen/include/pybind11/detail/descr.h +55 -0
  54. netgen/include/pybind11/detail/dynamic_raw_ptr_cast_if_possible.h +39 -0
  55. netgen/include/pybind11/detail/exception_translation.h +71 -0
  56. netgen/include/pybind11/detail/function_record_pyobject.h +191 -0
  57. netgen/include/pybind11/detail/init.h +113 -9
  58. netgen/include/pybind11/detail/internals.h +479 -344
  59. netgen/include/pybind11/detail/native_enum_data.h +209 -0
  60. netgen/include/pybind11/detail/pybind11_namespace_macros.h +82 -0
  61. netgen/include/pybind11/detail/struct_smart_holder.h +378 -0
  62. netgen/include/pybind11/detail/type_caster_base.h +506 -133
  63. netgen/include/pybind11/detail/using_smart_holder.h +22 -0
  64. netgen/include/pybind11/detail/value_and_holder.h +90 -0
  65. netgen/include/pybind11/eigen/matrix.h +19 -10
  66. netgen/include/pybind11/eigen/tensor.h +15 -11
  67. netgen/include/pybind11/embed.h +50 -46
  68. netgen/include/pybind11/eval.h +11 -6
  69. netgen/include/pybind11/functional.h +58 -49
  70. netgen/include/pybind11/gil.h +34 -82
  71. netgen/include/pybind11/gil_safe_call_once.h +12 -1
  72. netgen/include/pybind11/gil_simple.h +37 -0
  73. netgen/include/pybind11/native_enum.h +67 -0
  74. netgen/include/pybind11/numpy.h +272 -93
  75. netgen/include/pybind11/pybind11.h +947 -265
  76. netgen/include/pybind11/pytypes.h +127 -21
  77. netgen/include/pybind11/stl/filesystem.h +23 -25
  78. netgen/include/pybind11/stl.h +277 -59
  79. netgen/include/pybind11/stl_bind.h +42 -7
  80. netgen/include/pybind11/subinterpreter.h +299 -0
  81. netgen/include/pybind11/trampoline_self_life_support.h +65 -0
  82. netgen/include/pybind11/typing.h +177 -4
  83. netgen/include/pybind11/warnings.h +75 -0
  84. netgen/include/visualization/mvdraw.hpp +48 -12
  85. netgen/include/visualization/vssolution.hpp +3 -1
  86. netgen/lib/libnggui.lib +0 -0
  87. netgen/lib/ngcore.lib +0 -0
  88. netgen/lib/nglib.lib +0 -0
  89. netgen/libnggui.dll +0 -0
  90. netgen/libngguipy.pyd +0 -0
  91. netgen/libngpy/_NgOCC.pyi +224 -139
  92. netgen/libngpy/_csg.pyi +26 -26
  93. netgen/libngpy/_geom2d.pyi +34 -25
  94. netgen/libngpy/_meshing.pyi +262 -111
  95. netgen/libngpy/_stl.pyi +3 -4
  96. netgen/libngpy.pyd +0 -0
  97. netgen/ngcore.dll +0 -0
  98. netgen/nglib.dll +0 -0
  99. netgen/read_gmsh.py +41 -0
  100. netgen/togl.dll +0 -0
  101. netgen/version.py +1 -1
  102. netgen/webgui.py +38 -2
  103. {netgen_mesher-6.2.2504.post11.dev0.dist-info → netgen_mesher-6.2.2506.post48.dev0.dist-info}/METADATA +2 -1
  104. {netgen_mesher-6.2.2504.post11.dev0.dist-info → netgen_mesher-6.2.2506.post48.dev0.dist-info}/RECORD +153 -132
  105. pyngcore/pyngcore.cp313-win_amd64.pyd +0 -0
  106. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/boundarycondition.geo +0 -0
  107. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/boxcyl.geo +0 -0
  108. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/circle_on_cube.geo +0 -0
  109. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/cone.geo +0 -0
  110. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/cube.geo +0 -0
  111. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/cubeandring.geo +0 -0
  112. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/cubeandspheres.geo +0 -0
  113. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/cubemcyl.geo +0 -0
  114. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/cubemsphere.geo +0 -0
  115. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/cylinder.geo +0 -0
  116. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/cylsphere.geo +0 -0
  117. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/doc/ng4.pdf +0 -0
  118. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/ellipsoid.geo +0 -0
  119. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/ellipticcyl.geo +0 -0
  120. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/extrusion.geo +0 -0
  121. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/fichera.geo +0 -0
  122. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/frame.step +0 -0
  123. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/hinge.stl +0 -0
  124. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/lshape3d.geo +0 -0
  125. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/manyholes.geo +0 -0
  126. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/manyholes2.geo +0 -0
  127. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/matrix.geo +0 -0
  128. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/ortho.geo +0 -0
  129. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/part1.stl +0 -0
  130. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/period.geo +0 -0
  131. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/py_tutorials/exportNeutral.py +0 -0
  132. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/py_tutorials/mesh.py +0 -0
  133. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/py_tutorials/shaft.geo +0 -0
  134. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/revolution.geo +0 -0
  135. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/screw.step +0 -0
  136. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/sculpture.geo +0 -0
  137. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/shaft.geo +0 -0
  138. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/shell.geo +0 -0
  139. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/sphere.geo +0 -0
  140. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/sphereincube.geo +0 -0
  141. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/square.in2d +0 -0
  142. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/squarecircle.in2d +0 -0
  143. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/squarehole.in2d +0 -0
  144. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/torus.geo +0 -0
  145. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/trafo.geo +0 -0
  146. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/twobricks.geo +0 -0
  147. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/twocubes.geo +0 -0
  148. {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/twocyl.geo +0 -0
  149. {netgen_mesher-6.2.2504.post11.dev0.dist-info → netgen_mesher-6.2.2506.post48.dev0.dist-info}/AUTHORS +0 -0
  150. {netgen_mesher-6.2.2504.post11.dev0.dist-info → netgen_mesher-6.2.2506.post48.dev0.dist-info}/LICENSE +0 -0
  151. {netgen_mesher-6.2.2504.post11.dev0.dist-info → netgen_mesher-6.2.2506.post48.dev0.dist-info}/WHEEL +0 -0
  152. {netgen_mesher-6.2.2504.post11.dev0.dist-info → netgen_mesher-6.2.2506.post48.dev0.dist-info}/entry_points.txt +0 -0
  153. {netgen_mesher-6.2.2504.post11.dev0.dist-info → netgen_mesher-6.2.2506.post48.dev0.dist-info}/top_level.txt +0 -0
@@ -9,26 +9,38 @@
9
9
 
10
10
  #pragma once
11
11
 
12
- #include "detail/common.h"
12
+ #if defined(PYBIND11_SIMPLE_GIL_MANAGEMENT)
13
13
 
14
- #include <cassert>
14
+ # include "detail/common.h"
15
+ # include "gil_simple.h"
15
16
 
16
- #if defined(WITH_THREAD) && !defined(PYBIND11_SIMPLE_GIL_MANAGEMENT)
17
+ PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
18
+
19
+ using gil_scoped_acquire = gil_scoped_acquire_simple;
20
+ using gil_scoped_release = gil_scoped_release_simple;
21
+
22
+ PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
23
+
24
+ #else
25
+
26
+ # include "detail/common.h"
17
27
  # include "detail/internals.h"
18
- #endif
28
+
29
+ # include <cassert>
19
30
 
20
31
  PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
21
32
 
22
33
  PYBIND11_NAMESPACE_BEGIN(detail)
23
34
 
35
+ PYBIND11_WARNING_PUSH
36
+ PYBIND11_WARNING_DISABLE_GCC("-Wredundant-decls")
37
+
24
38
  // forward declarations
25
39
  PyThreadState *get_thread_state_unchecked();
26
40
 
27
- PYBIND11_NAMESPACE_END(detail)
28
-
29
- #if defined(WITH_THREAD)
41
+ PYBIND11_WARNING_POP
30
42
 
31
- # if !defined(PYBIND11_SIMPLE_GIL_MANAGEMENT)
43
+ PYBIND11_NAMESPACE_END(detail)
32
44
 
33
45
  /* The functions below essentially reproduce the PyGILState_* API using a RAII
34
46
  * pattern, but there are a few important differences:
@@ -56,7 +68,7 @@ class gil_scoped_acquire {
56
68
  public:
57
69
  PYBIND11_NOINLINE gil_scoped_acquire() {
58
70
  auto &internals = detail::get_internals();
59
- tstate = (PyThreadState *) PYBIND11_TLS_GET_VALUE(internals.tstate);
71
+ tstate = internals.tstate.get();
60
72
 
61
73
  if (!tstate) {
62
74
  /* Check if the GIL was acquired using the PyGILState_* API instead (e.g. if
@@ -69,13 +81,13 @@ public:
69
81
 
70
82
  if (!tstate) {
71
83
  tstate = PyThreadState_New(internals.istate);
72
- # if defined(PYBIND11_DETAILED_ERROR_MESSAGES)
84
+ # if defined(PYBIND11_DETAILED_ERROR_MESSAGES)
73
85
  if (!tstate) {
74
86
  pybind11_fail("scoped_acquire: could not create thread state!");
75
87
  }
76
- # endif
88
+ # endif
77
89
  tstate->gilstate_counter = 0;
78
- PYBIND11_TLS_REPLACE_VALUE(internals.tstate, tstate);
90
+ internals.tstate = tstate;
79
91
  } else {
80
92
  release = detail::get_thread_state_unchecked() != tstate;
81
93
  }
@@ -94,31 +106,31 @@ public:
94
106
 
95
107
  PYBIND11_NOINLINE void dec_ref() {
96
108
  --tstate->gilstate_counter;
97
- # if defined(PYBIND11_DETAILED_ERROR_MESSAGES)
109
+ # if defined(PYBIND11_DETAILED_ERROR_MESSAGES)
98
110
  if (detail::get_thread_state_unchecked() != tstate) {
99
111
  pybind11_fail("scoped_acquire::dec_ref(): thread state must be current!");
100
112
  }
101
113
  if (tstate->gilstate_counter < 0) {
102
114
  pybind11_fail("scoped_acquire::dec_ref(): reference count underflow!");
103
115
  }
104
- # endif
116
+ # endif
105
117
  if (tstate->gilstate_counter == 0) {
106
- # if defined(PYBIND11_DETAILED_ERROR_MESSAGES)
118
+ # if defined(PYBIND11_DETAILED_ERROR_MESSAGES)
107
119
  if (!release) {
108
120
  pybind11_fail("scoped_acquire::dec_ref(): internal error!");
109
121
  }
110
- # endif
122
+ # endif
111
123
  PyThreadState_Clear(tstate);
112
124
  if (active) {
113
125
  PyThreadState_DeleteCurrent();
114
126
  }
115
- PYBIND11_TLS_DELETE_VALUE(detail::get_internals().tstate);
127
+ detail::get_internals().tstate.reset();
116
128
  release = false;
117
129
  }
118
130
  }
119
131
 
120
132
  /// This method will disable the PyThreadState_DeleteCurrent call and the
121
- /// GIL won't be acquired. This method should be used if the interpreter
133
+ /// GIL won't be released. This method should be used if the interpreter
122
134
  /// could be shutting down when this is called, as thread deletion is not
123
135
  /// allowed during shutdown. Check _Py_IsFinalizing() on Python 3.7+, and
124
136
  /// protect subsequent code.
@@ -149,10 +161,7 @@ public:
149
161
  // NOLINTNEXTLINE(cppcoreguidelines-prefer-member-initializer)
150
162
  tstate = PyEval_SaveThread();
151
163
  if (disassoc) {
152
- // Python >= 3.7 can remove this, it's an int before 3.7
153
- // NOLINTNEXTLINE(readability-qualified-auto)
154
- auto key = internals.tstate;
155
- PYBIND11_TLS_DELETE_VALUE(key);
164
+ internals.tstate.reset();
156
165
  }
157
166
  }
158
167
 
@@ -175,10 +184,7 @@ public:
175
184
  PyEval_RestoreThread(tstate);
176
185
  }
177
186
  if (disassoc) {
178
- // Python >= 3.7 can remove this, it's an int before 3.7
179
- // NOLINTNEXTLINE(readability-qualified-auto)
180
- auto key = detail::get_internals().tstate;
181
- PYBIND11_TLS_REPLACE_VALUE(key, tstate);
187
+ detail::get_internals().tstate = tstate;
182
188
  }
183
189
  }
184
190
 
@@ -188,60 +194,6 @@ private:
188
194
  bool active = true;
189
195
  };
190
196
 
191
- # else // PYBIND11_SIMPLE_GIL_MANAGEMENT
192
-
193
- class gil_scoped_acquire {
194
- PyGILState_STATE state;
195
-
196
- public:
197
- gil_scoped_acquire() : state{PyGILState_Ensure()} {}
198
- gil_scoped_acquire(const gil_scoped_acquire &) = delete;
199
- gil_scoped_acquire &operator=(const gil_scoped_acquire &) = delete;
200
- ~gil_scoped_acquire() { PyGILState_Release(state); }
201
- void disarm() {}
202
- };
203
-
204
- class gil_scoped_release {
205
- PyThreadState *state;
206
-
207
- public:
208
- // PRECONDITION: The GIL must be held when this constructor is called.
209
- gil_scoped_release() {
210
- assert(PyGILState_Check());
211
- state = PyEval_SaveThread();
212
- }
213
- gil_scoped_release(const gil_scoped_release &) = delete;
214
- gil_scoped_release &operator=(const gil_scoped_release &) = delete;
215
- ~gil_scoped_release() { PyEval_RestoreThread(state); }
216
- void disarm() {}
217
- };
218
-
219
- # endif // PYBIND11_SIMPLE_GIL_MANAGEMENT
220
-
221
- #else // WITH_THREAD
222
-
223
- class gil_scoped_acquire {
224
- public:
225
- gil_scoped_acquire() {
226
- // Trick to suppress `unused variable` error messages (at call sites).
227
- (void) (this != (this + 1));
228
- }
229
- gil_scoped_acquire(const gil_scoped_acquire &) = delete;
230
- gil_scoped_acquire &operator=(const gil_scoped_acquire &) = delete;
231
- void disarm() {}
232
- };
233
-
234
- class gil_scoped_release {
235
- public:
236
- gil_scoped_release() {
237
- // Trick to suppress `unused variable` error messages (at call sites).
238
- (void) (this != (this + 1));
239
- }
240
- gil_scoped_release(const gil_scoped_release &) = delete;
241
- gil_scoped_release &operator=(const gil_scoped_release &) = delete;
242
- void disarm() {}
243
- };
244
-
245
- #endif // WITH_THREAD
246
-
247
197
  PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
198
+
199
+ #endif // !PYBIND11_SIMPLE_GIL_MANAGEMENT
@@ -8,6 +8,10 @@
8
8
  #include <cassert>
9
9
  #include <mutex>
10
10
 
11
+ #ifdef Py_GIL_DISABLED
12
+ # include <atomic>
13
+ #endif
14
+
11
15
  PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
12
16
 
13
17
  // Use the `gil_safe_call_once_and_store` class below instead of the naive
@@ -42,6 +46,8 @@ PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
42
46
  // get processed only when it is the main thread's turn again and it is running
43
47
  // normal Python code. However, this will be unnoticeable for quick call-once
44
48
  // functions, which is usually the case.
49
+ //
50
+ // For in-depth background, see docs/advanced/deadlock.md
45
51
  template <typename T>
46
52
  class gil_safe_call_once_and_store {
47
53
  public:
@@ -82,7 +88,12 @@ public:
82
88
  private:
83
89
  alignas(T) char storage_[sizeof(T)] = {};
84
90
  std::once_flag once_flag_ = {};
85
- bool is_initialized_ = false;
91
+ #ifdef Py_GIL_DISABLED
92
+ std::atomic_bool
93
+ #else
94
+ bool
95
+ #endif
96
+ is_initialized_{false};
86
97
  // The `is_initialized_`-`storage_` pair is very similar to `std::optional`,
87
98
  // but the latter does not have the triviality properties of former,
88
99
  // therefore `std::optional` is not a viable alternative here.
@@ -0,0 +1,37 @@
1
+ // Copyright (c) 2016-2025 The Pybind Development Team.
2
+ // All rights reserved. Use of this source code is governed by a
3
+ // BSD-style license that can be found in the LICENSE file.
4
+
5
+ #pragma once
6
+
7
+ #include "detail/common.h"
8
+
9
+ #include <cassert>
10
+
11
+ PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
12
+
13
+ class gil_scoped_acquire_simple {
14
+ PyGILState_STATE state;
15
+
16
+ public:
17
+ gil_scoped_acquire_simple() : state{PyGILState_Ensure()} {}
18
+ gil_scoped_acquire_simple(const gil_scoped_acquire_simple &) = delete;
19
+ gil_scoped_acquire_simple &operator=(const gil_scoped_acquire_simple &) = delete;
20
+ ~gil_scoped_acquire_simple() { PyGILState_Release(state); }
21
+ };
22
+
23
+ class gil_scoped_release_simple {
24
+ PyThreadState *state;
25
+
26
+ public:
27
+ // PRECONDITION: The GIL must be held when this constructor is called.
28
+ gil_scoped_release_simple() {
29
+ assert(PyGILState_Check());
30
+ state = PyEval_SaveThread();
31
+ }
32
+ gil_scoped_release_simple(const gil_scoped_release_simple &) = delete;
33
+ gil_scoped_release_simple &operator=(const gil_scoped_release_simple &) = delete;
34
+ ~gil_scoped_release_simple() { PyEval_RestoreThread(state); }
35
+ };
36
+
37
+ PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
@@ -0,0 +1,67 @@
1
+ // Copyright (c) 2022-2025 The pybind Community.
2
+ // All rights reserved. Use of this source code is governed by a
3
+ // BSD-style license that can be found in the LICENSE file.
4
+
5
+ #pragma once
6
+
7
+ #include "detail/common.h"
8
+ #include "detail/native_enum_data.h"
9
+ #include "detail/type_caster_base.h"
10
+ #include "cast.h"
11
+
12
+ #include <cassert>
13
+ #include <limits>
14
+ #include <type_traits>
15
+ #include <typeindex>
16
+
17
+ PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
18
+
19
+ /// Conversions between Python's native (stdlib) enum types and C++ enums.
20
+ template <typename EnumType>
21
+ class native_enum : public detail::native_enum_data {
22
+ public:
23
+ using Underlying = typename std::underlying_type<EnumType>::type;
24
+
25
+ native_enum(const object &parent_scope,
26
+ const char *name,
27
+ const char *native_type_name,
28
+ const char *class_doc = "")
29
+ : detail::native_enum_data(
30
+ parent_scope, name, native_type_name, class_doc, std::type_index(typeid(EnumType))) {
31
+ if (detail::get_local_type_info(typeid(EnumType)) != nullptr
32
+ || detail::get_global_type_info(typeid(EnumType)) != nullptr) {
33
+ pybind11_fail(
34
+ "pybind11::native_enum<...>(\"" + enum_name_encoded
35
+ + "\") is already registered as a `pybind11::enum_` or `pybind11::class_`!");
36
+ }
37
+ if (detail::global_internals_native_enum_type_map_contains(enum_type_index)) {
38
+ pybind11_fail("pybind11::native_enum<...>(\"" + enum_name_encoded
39
+ + "\") is already registered!");
40
+ }
41
+ arm_finalize_check();
42
+ }
43
+
44
+ /// Export enumeration entries into the parent scope
45
+ native_enum &export_values() {
46
+ assert(!export_values_flag); // Catch redundant calls.
47
+ export_values_flag = true;
48
+ return *this;
49
+ }
50
+
51
+ /// Add an enumeration entry
52
+ native_enum &value(char const *name, EnumType value, const char *doc = nullptr) {
53
+ // Disarm for the case that the native_enum_data dtor runs during exception unwinding.
54
+ disarm_finalize_check("value after finalize");
55
+ members.append(make_tuple(name, static_cast<Underlying>(value)));
56
+ if (doc) {
57
+ member_docs.append(make_tuple(name, doc));
58
+ }
59
+ arm_finalize_check(); // There was no exception.
60
+ return *this;
61
+ }
62
+
63
+ native_enum(const native_enum &) = delete;
64
+ native_enum &operator=(const native_enum &) = delete;
65
+ };
66
+
67
+ PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)