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.
- netgen/__init__.pyi +3 -3
- netgen/cmake/NetgenConfig.cmake +10 -9
- netgen/config/__init__.pyi +8 -8
- netgen/config/config.py +7 -7
- netgen/config/config.pyi +8 -8
- netgen/include/core/archive.hpp +18 -3
- netgen/include/core/array.hpp +20 -4
- netgen/include/core/autodiff.hpp +9 -11
- netgen/include/core/autodiffdiff.hpp +0 -2
- netgen/include/core/bitarray.hpp +1 -1
- netgen/include/core/flags.hpp +1 -1
- netgen/include/core/hashtable.hpp +1 -1
- netgen/include/core/memtracer.hpp +7 -7
- netgen/include/core/ngcore.hpp +5 -0
- netgen/include/core/ngcore_api.hpp +11 -0
- netgen/include/core/paje_trace.hpp +9 -8
- netgen/include/core/profiler.hpp +5 -5
- netgen/include/core/register_archive.hpp +8 -0
- netgen/include/core/simd.hpp +69 -1
- netgen/include/core/simd_arm64.hpp +205 -1
- netgen/include/core/simd_avx.hpp +72 -4
- netgen/include/core/simd_avx512.hpp +9 -0
- netgen/include/core/simd_generic.hpp +274 -8
- netgen/include/core/simd_math.hpp +178 -0
- netgen/include/core/simd_sse.hpp +11 -1
- netgen/include/core/statushandler.hpp +37 -0
- netgen/include/core/table.hpp +3 -2
- netgen/include/core/taskmanager.hpp +34 -1
- netgen/include/core/utils.hpp +3 -8
- netgen/include/include/netgen_version.hpp +4 -4
- netgen/include/meshing/basegeom.hpp +1 -4
- netgen/include/meshing/global.hpp +0 -17
- netgen/include/meshing/hpref_tet.hpp +41 -0
- netgen/include/meshing/hprefinement.hpp +2 -0
- netgen/include/meshing/meshtype.hpp +2 -1
- netgen/include/meshing/msghandler.hpp +9 -6
- netgen/include/meshing/topology.hpp +2 -2
- netgen/include/nginterface.h +3 -2
- netgen/include/occ/occ_utils.hpp +26 -0
- netgen/include/occ/occgeom.hpp +8 -0
- netgen/include/pybind11/attr.h +40 -8
- netgen/include/pybind11/buffer_info.h +14 -14
- netgen/include/pybind11/cast.h +553 -29
- netgen/include/pybind11/chrono.h +4 -1
- netgen/include/pybind11/conduit/README.txt +15 -0
- netgen/include/pybind11/conduit/pybind11_conduit_v1.h +116 -0
- netgen/include/pybind11/conduit/pybind11_platform_abi_id.h +87 -0
- netgen/include/pybind11/conduit/wrap_include_python_h.h +72 -0
- netgen/include/pybind11/critical_section.h +56 -0
- netgen/include/pybind11/detail/class.h +172 -97
- netgen/include/pybind11/detail/common.h +270 -189
- netgen/include/pybind11/detail/cpp_conduit.h +75 -0
- netgen/include/pybind11/detail/descr.h +55 -0
- netgen/include/pybind11/detail/dynamic_raw_ptr_cast_if_possible.h +39 -0
- netgen/include/pybind11/detail/exception_translation.h +71 -0
- netgen/include/pybind11/detail/function_record_pyobject.h +191 -0
- netgen/include/pybind11/detail/init.h +113 -9
- netgen/include/pybind11/detail/internals.h +479 -344
- netgen/include/pybind11/detail/native_enum_data.h +209 -0
- netgen/include/pybind11/detail/pybind11_namespace_macros.h +82 -0
- netgen/include/pybind11/detail/struct_smart_holder.h +378 -0
- netgen/include/pybind11/detail/type_caster_base.h +506 -133
- netgen/include/pybind11/detail/using_smart_holder.h +22 -0
- netgen/include/pybind11/detail/value_and_holder.h +90 -0
- netgen/include/pybind11/eigen/matrix.h +19 -10
- netgen/include/pybind11/eigen/tensor.h +15 -11
- netgen/include/pybind11/embed.h +50 -46
- netgen/include/pybind11/eval.h +11 -6
- netgen/include/pybind11/functional.h +58 -49
- netgen/include/pybind11/gil.h +34 -82
- netgen/include/pybind11/gil_safe_call_once.h +12 -1
- netgen/include/pybind11/gil_simple.h +37 -0
- netgen/include/pybind11/native_enum.h +67 -0
- netgen/include/pybind11/numpy.h +272 -93
- netgen/include/pybind11/pybind11.h +947 -265
- netgen/include/pybind11/pytypes.h +127 -21
- netgen/include/pybind11/stl/filesystem.h +23 -25
- netgen/include/pybind11/stl.h +277 -59
- netgen/include/pybind11/stl_bind.h +42 -7
- netgen/include/pybind11/subinterpreter.h +299 -0
- netgen/include/pybind11/trampoline_self_life_support.h +65 -0
- netgen/include/pybind11/typing.h +177 -4
- netgen/include/pybind11/warnings.h +75 -0
- netgen/include/visualization/mvdraw.hpp +48 -12
- netgen/include/visualization/vssolution.hpp +3 -1
- netgen/lib/libnggui.lib +0 -0
- netgen/lib/ngcore.lib +0 -0
- netgen/lib/nglib.lib +0 -0
- netgen/libnggui.dll +0 -0
- netgen/libngguipy.pyd +0 -0
- netgen/libngpy/_NgOCC.pyi +224 -139
- netgen/libngpy/_csg.pyi +26 -26
- netgen/libngpy/_geom2d.pyi +34 -25
- netgen/libngpy/_meshing.pyi +262 -111
- netgen/libngpy/_stl.pyi +3 -4
- netgen/libngpy.pyd +0 -0
- netgen/ngcore.dll +0 -0
- netgen/nglib.dll +0 -0
- netgen/read_gmsh.py +41 -0
- netgen/togl.dll +0 -0
- netgen/version.py +1 -1
- netgen/webgui.py +38 -2
- {netgen_mesher-6.2.2504.post11.dev0.dist-info → netgen_mesher-6.2.2506.post48.dev0.dist-info}/METADATA +2 -1
- {netgen_mesher-6.2.2504.post11.dev0.dist-info → netgen_mesher-6.2.2506.post48.dev0.dist-info}/RECORD +153 -132
- pyngcore/pyngcore.cp313-win_amd64.pyd +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/boundarycondition.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/boxcyl.geo +0 -0
- {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
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/cone.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/cube.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/cubeandring.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/cubeandspheres.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/cubemcyl.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/cubemsphere.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/cylinder.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/cylsphere.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/doc/ng4.pdf +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/ellipsoid.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/ellipticcyl.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/extrusion.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/fichera.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/frame.step +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/hinge.stl +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/lshape3d.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/manyholes.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/manyholes2.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/matrix.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/ortho.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/part1.stl +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/period.geo +0 -0
- {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
- {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
- {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
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/revolution.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/screw.step +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/sculpture.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/shaft.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/shell.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/sphere.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/sphereincube.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/square.in2d +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/squarecircle.in2d +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/squarehole.in2d +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/torus.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/trafo.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/twobricks.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/twocubes.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.data → netgen_mesher-6.2.2506.post48.dev0.data}/data/share/netgen/twocyl.geo +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.dist-info → netgen_mesher-6.2.2506.post48.dev0.dist-info}/AUTHORS +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.dist-info → netgen_mesher-6.2.2506.post48.dev0.dist-info}/LICENSE +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.dist-info → netgen_mesher-6.2.2506.post48.dev0.dist-info}/WHEEL +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.dist-info → netgen_mesher-6.2.2506.post48.dev0.dist-info}/entry_points.txt +0 -0
- {netgen_mesher-6.2.2504.post11.dev0.dist-info → netgen_mesher-6.2.2506.post48.dev0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright (c) 2024 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 "common.h"
|
|
8
|
+
#include "struct_smart_holder.h"
|
|
9
|
+
|
|
10
|
+
#include <type_traits>
|
|
11
|
+
|
|
12
|
+
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
|
|
13
|
+
|
|
14
|
+
using pybind11::memory::smart_holder;
|
|
15
|
+
|
|
16
|
+
PYBIND11_NAMESPACE_BEGIN(detail)
|
|
17
|
+
|
|
18
|
+
template <typename H>
|
|
19
|
+
using is_smart_holder = std::is_same<H, smart_holder>;
|
|
20
|
+
|
|
21
|
+
PYBIND11_NAMESPACE_END(detail)
|
|
22
|
+
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// Copyright (c) 2016-2024 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 "common.h"
|
|
8
|
+
|
|
9
|
+
#include <cstddef>
|
|
10
|
+
#include <cstdint>
|
|
11
|
+
#include <typeinfo>
|
|
12
|
+
|
|
13
|
+
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
|
|
14
|
+
PYBIND11_NAMESPACE_BEGIN(detail)
|
|
15
|
+
|
|
16
|
+
struct value_and_holder {
|
|
17
|
+
instance *inst = nullptr;
|
|
18
|
+
size_t index = 0u;
|
|
19
|
+
const detail::type_info *type = nullptr;
|
|
20
|
+
void **vh = nullptr;
|
|
21
|
+
|
|
22
|
+
// Main constructor for a found value/holder:
|
|
23
|
+
value_and_holder(instance *i, const detail::type_info *type, size_t vpos, size_t index)
|
|
24
|
+
: inst{i}, index{index}, type{type},
|
|
25
|
+
vh{inst->simple_layout ? inst->simple_value_holder
|
|
26
|
+
: &inst->nonsimple.values_and_holders[vpos]} {}
|
|
27
|
+
|
|
28
|
+
// Default constructor (used to signal a value-and-holder not found by get_value_and_holder())
|
|
29
|
+
value_and_holder() = default;
|
|
30
|
+
|
|
31
|
+
// Used for past-the-end iterator
|
|
32
|
+
explicit value_and_holder(size_t index) : index{index} {}
|
|
33
|
+
|
|
34
|
+
template <typename V = void>
|
|
35
|
+
V *&value_ptr() const {
|
|
36
|
+
return reinterpret_cast<V *&>(vh[0]);
|
|
37
|
+
}
|
|
38
|
+
// True if this `value_and_holder` has a non-null value pointer
|
|
39
|
+
explicit operator bool() const { return value_ptr() != nullptr; }
|
|
40
|
+
|
|
41
|
+
template <typename H>
|
|
42
|
+
H &holder() const {
|
|
43
|
+
return reinterpret_cast<H &>(vh[1]);
|
|
44
|
+
}
|
|
45
|
+
bool holder_constructed() const {
|
|
46
|
+
return inst->simple_layout
|
|
47
|
+
? inst->simple_holder_constructed
|
|
48
|
+
: (inst->nonsimple.status[index] & instance::status_holder_constructed) != 0u;
|
|
49
|
+
}
|
|
50
|
+
// NOLINTNEXTLINE(readability-make-member-function-const)
|
|
51
|
+
void set_holder_constructed(bool v = true) {
|
|
52
|
+
if (inst->simple_layout) {
|
|
53
|
+
inst->simple_holder_constructed = v;
|
|
54
|
+
} else if (v) {
|
|
55
|
+
inst->nonsimple.status[index] |= instance::status_holder_constructed;
|
|
56
|
+
} else {
|
|
57
|
+
inst->nonsimple.status[index] &= (std::uint8_t) ~instance::status_holder_constructed;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
bool instance_registered() const {
|
|
61
|
+
return inst->simple_layout
|
|
62
|
+
? inst->simple_instance_registered
|
|
63
|
+
: ((inst->nonsimple.status[index] & instance::status_instance_registered) != 0);
|
|
64
|
+
}
|
|
65
|
+
// NOLINTNEXTLINE(readability-make-member-function-const)
|
|
66
|
+
void set_instance_registered(bool v = true) {
|
|
67
|
+
if (inst->simple_layout) {
|
|
68
|
+
inst->simple_instance_registered = v;
|
|
69
|
+
} else if (v) {
|
|
70
|
+
inst->nonsimple.status[index] |= instance::status_instance_registered;
|
|
71
|
+
} else {
|
|
72
|
+
inst->nonsimple.status[index] &= (std::uint8_t) ~instance::status_instance_registered;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
// This is a semi-public API to check if the corresponding instance has been constructed with a
|
|
78
|
+
// holder. That is, if the instance has been constructed with a holder, the `__init__` method is
|
|
79
|
+
// called and the C++ object is valid. Otherwise, the C++ object might only be allocated, but not
|
|
80
|
+
// initialized. This will lead to **SEGMENTATION FAULTS** if the C++ object is used in any way.
|
|
81
|
+
// Example usage: https://pybind11.readthedocs.io/en/stable/advanced/classes.html#custom-type-setup
|
|
82
|
+
// for `tp_traverse` and `tp_clear` implementations.
|
|
83
|
+
// WARNING: The caller is responsible for ensuring that the `reinterpret_cast` is valid.
|
|
84
|
+
inline bool is_holder_constructed(PyObject *obj) {
|
|
85
|
+
auto *const instance = reinterpret_cast<pybind11::detail::instance *>(obj);
|
|
86
|
+
return instance->get_value_and_holder().holder_constructed();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
PYBIND11_NAMESPACE_END(detail)
|
|
90
|
+
PYBIND11_NAMESPACE_END(PYBIND11_NAMESPACE)
|
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
#pragma once
|
|
11
11
|
|
|
12
|
-
#include
|
|
12
|
+
#include <pybind11/numpy.h>
|
|
13
|
+
|
|
13
14
|
#include "common.h"
|
|
14
15
|
|
|
15
16
|
/* HINT: To suppress warnings originating from the Eigen headers, use -isystem.
|
|
@@ -224,19 +225,22 @@ struct EigenProps {
|
|
|
224
225
|
= !show_c_contiguous && show_order && requires_col_major;
|
|
225
226
|
|
|
226
227
|
static constexpr auto descriptor
|
|
227
|
-
= const_name("
|
|
228
|
+
= const_name("typing.Annotated[")
|
|
229
|
+
+ io_name("numpy.typing.ArrayLike, ", "numpy.typing.NDArray[")
|
|
230
|
+
+ npy_format_descriptor<Scalar>::name + io_name("", "]") + const_name(", \"[")
|
|
228
231
|
+ const_name<fixed_rows>(const_name<(size_t) rows>(), const_name("m")) + const_name(", ")
|
|
229
|
-
+ const_name<fixed_cols>(const_name<(size_t) cols>(), const_name("n"))
|
|
230
|
-
+
|
|
232
|
+
+ const_name<fixed_cols>(const_name<(size_t) cols>(), const_name("n"))
|
|
233
|
+
+ const_name("]\"")
|
|
231
234
|
// For a reference type (e.g. Ref<MatrixXd>) we have other constraints that might need to
|
|
232
235
|
// be satisfied: writeable=True (for a mutable reference), and, depending on the map's
|
|
233
236
|
// stride options, possibly f_contiguous or c_contiguous. We include them in the
|
|
234
237
|
// descriptor output to provide some hint as to why a TypeError is occurring (otherwise
|
|
235
|
-
// it can be confusing to see that a function accepts a
|
|
236
|
-
//
|
|
237
|
-
|
|
238
|
-
+ const_name<
|
|
239
|
-
+ const_name<
|
|
238
|
+
// it can be confusing to see that a function accepts a
|
|
239
|
+
// 'typing.Annotated[numpy.typing.NDArray[numpy.float64], "[3,2]"]' and an error message
|
|
240
|
+
// that you *gave* a numpy.ndarray of the right type and dimensions.
|
|
241
|
+
+ const_name<show_writeable>(", \"flags.writeable\"", "")
|
|
242
|
+
+ const_name<show_c_contiguous>(", \"flags.c_contiguous\"", "")
|
|
243
|
+
+ const_name<show_f_contiguous>(", \"flags.f_contiguous\"", "") + const_name("]");
|
|
240
244
|
};
|
|
241
245
|
|
|
242
246
|
// Casts an Eigen type to numpy array. If given a base, the numpy array references the src data,
|
|
@@ -315,8 +319,11 @@ struct type_caster<Type, enable_if_t<is_eigen_dense_plain<Type>::value>> {
|
|
|
315
319
|
return false;
|
|
316
320
|
}
|
|
317
321
|
|
|
322
|
+
PYBIND11_WARNING_PUSH
|
|
323
|
+
PYBIND11_WARNING_DISABLE_GCC("-Wmaybe-uninitialized") // See PR #5516
|
|
318
324
|
// Allocate the new type, then build a numpy reference into it
|
|
319
325
|
value = Type(fits.rows, fits.cols);
|
|
326
|
+
PYBIND11_WARNING_POP
|
|
320
327
|
auto ref = reinterpret_steal<array>(eigen_ref_array<props>(value));
|
|
321
328
|
if (dims == 1) {
|
|
322
329
|
ref = ref.squeeze();
|
|
@@ -437,7 +444,9 @@ public:
|
|
|
437
444
|
}
|
|
438
445
|
}
|
|
439
446
|
|
|
440
|
-
|
|
447
|
+
// return_descr forces the use of NDArray instead of ArrayLike in args
|
|
448
|
+
// since Ref<...> args can only accept arrays.
|
|
449
|
+
static constexpr auto name = return_descr(props::descriptor);
|
|
441
450
|
|
|
442
451
|
// Explicitly delete these: support python -> C++ conversion on these (i.e. these can be return
|
|
443
452
|
// types but not bound arguments). We still provide them (with an explicitly delete) so that
|
|
@@ -7,7 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
#pragma once
|
|
9
9
|
|
|
10
|
-
#include
|
|
10
|
+
#include <pybind11/numpy.h>
|
|
11
|
+
|
|
11
12
|
#include "common.h"
|
|
12
13
|
|
|
13
14
|
#if defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER)
|
|
@@ -123,13 +124,16 @@ struct eigen_tensor_helper<
|
|
|
123
124
|
template <typename Type, bool ShowDetails, bool NeedsWriteable = false>
|
|
124
125
|
struct get_tensor_descriptor {
|
|
125
126
|
static constexpr auto details
|
|
126
|
-
= const_name<NeedsWriteable>(", flags.writeable", "")
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
= const_name<NeedsWriteable>(", \"flags.writeable\"", "") + const_name
|
|
128
|
+
< static_cast<int>(Type::Layout)
|
|
129
|
+
== static_cast<int>(Eigen::RowMajor)
|
|
130
|
+
> (", \"flags.c_contiguous\"", ", \"flags.f_contiguous\"");
|
|
129
131
|
static constexpr auto value
|
|
130
|
-
= const_name("
|
|
131
|
-
+
|
|
132
|
-
+
|
|
132
|
+
= const_name("typing.Annotated[")
|
|
133
|
+
+ io_name("numpy.typing.ArrayLike, ", "numpy.typing.NDArray[")
|
|
134
|
+
+ npy_format_descriptor<typename Type::Scalar>::name + io_name("", "]")
|
|
135
|
+
+ const_name(", \"[") + eigen_tensor_helper<remove_cv_t<Type>>::dimensions_descriptor
|
|
136
|
+
+ const_name("]\"") + const_name<ShowDetails>(details, const_name("")) + const_name("]");
|
|
133
137
|
};
|
|
134
138
|
|
|
135
139
|
// When EIGEN_AVOID_STL_ARRAY is defined, Eigen::DSizes<T, 0> does not have the begin() member
|
|
@@ -469,9 +473,6 @@ struct type_caster<Eigen::TensorMap<Type, Options>,
|
|
|
469
473
|
parent_object = reinterpret_borrow<object>(parent);
|
|
470
474
|
break;
|
|
471
475
|
|
|
472
|
-
case return_value_policy::take_ownership:
|
|
473
|
-
delete src;
|
|
474
|
-
// fallthrough
|
|
475
476
|
default:
|
|
476
477
|
// move, take_ownership don't make any sense for a ref/map:
|
|
477
478
|
pybind11_fail("Invalid return_value_policy for Eigen Map type, must be either "
|
|
@@ -504,7 +505,10 @@ protected:
|
|
|
504
505
|
std::unique_ptr<MapType> value;
|
|
505
506
|
|
|
506
507
|
public:
|
|
507
|
-
|
|
508
|
+
// return_descr forces the use of NDArray instead of ArrayLike since refs can only reference
|
|
509
|
+
// arrays
|
|
510
|
+
static constexpr auto name
|
|
511
|
+
= return_descr(get_tensor_descriptor<Type, true, needs_writeable>::value);
|
|
508
512
|
explicit operator MapType *() { return value.get(); }
|
|
509
513
|
explicit operator MapType &() { return *value; }
|
|
510
514
|
explicit operator MapType &&() && { return std::move(*value); }
|
netgen/include/pybind11/embed.h
CHANGED
|
@@ -37,24 +37,32 @@
|
|
|
37
37
|
return "Hello, World!";
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
|
+
|
|
41
|
+
The third and subsequent macro arguments are optional, and can be used to
|
|
42
|
+
mark the module as supporting various Python features.
|
|
43
|
+
|
|
44
|
+
- ``mod_gil_not_used()``
|
|
45
|
+
- ``multiple_interpreters::per_interpreter_gil()``
|
|
46
|
+
- ``multiple_interpreters::shared_gil()``
|
|
47
|
+
- ``multiple_interpreters::not_supported()``
|
|
48
|
+
|
|
49
|
+
.. code-block:: cpp
|
|
50
|
+
|
|
51
|
+
PYBIND11_EMBEDDED_MODULE(example, m, py::mod_gil_not_used()) {
|
|
52
|
+
m.def("foo", []() {
|
|
53
|
+
return "Hello, Free-threaded World!";
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
40
57
|
\endrst */
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
auto m = ::pybind11::module_::create_extension_module( \
|
|
46
|
-
PYBIND11_TOSTRING(name), nullptr, &PYBIND11_CONCAT(pybind11_module_def_, name)); \
|
|
47
|
-
try { \
|
|
48
|
-
PYBIND11_CONCAT(pybind11_init_, name)(m); \
|
|
49
|
-
return m.ptr(); \
|
|
50
|
-
} \
|
|
51
|
-
PYBIND11_CATCH_INIT_EXCEPTIONS \
|
|
52
|
-
} \
|
|
53
|
-
PYBIND11_EMBEDDED_MODULE_IMPL(name) \
|
|
58
|
+
PYBIND11_WARNING_PUSH
|
|
59
|
+
PYBIND11_WARNING_DISABLE_CLANG("-Wgnu-zero-variadic-macro-arguments")
|
|
60
|
+
#define PYBIND11_EMBEDDED_MODULE(name, variable, ...) \
|
|
61
|
+
PYBIND11_MODULE_PYINIT(name, {}, ##__VA_ARGS__) \
|
|
54
62
|
::pybind11::detail::embedded_module PYBIND11_CONCAT(pybind11_module_, name)( \
|
|
55
|
-
PYBIND11_TOSTRING(name), PYBIND11_CONCAT(
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
PYBIND11_TOSTRING(name), PYBIND11_CONCAT(PyInit_, name)); \
|
|
64
|
+
PYBIND11_MODULE_EXEC(name, variable)
|
|
65
|
+
PYBIND11_WARNING_POP
|
|
58
66
|
|
|
59
67
|
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
|
|
60
68
|
PYBIND11_NAMESPACE_BEGIN(detail)
|
|
@@ -103,19 +111,6 @@ inline void initialize_interpreter_pre_pyconfig(bool init_signal_handlers,
|
|
|
103
111
|
bool add_program_dir_to_path) {
|
|
104
112
|
detail::precheck_interpreter();
|
|
105
113
|
Py_InitializeEx(init_signal_handlers ? 1 : 0);
|
|
106
|
-
# if defined(WITH_THREAD) && PY_VERSION_HEX < 0x03070000
|
|
107
|
-
PyEval_InitThreads();
|
|
108
|
-
# endif
|
|
109
|
-
|
|
110
|
-
// Before it was special-cased in python 3.8, passing an empty or null argv
|
|
111
|
-
// caused a segfault, so we have to reimplement the special case ourselves.
|
|
112
|
-
bool special_case = (argv == nullptr || argc <= 0);
|
|
113
|
-
|
|
114
|
-
const char *const empty_argv[]{"\0"};
|
|
115
|
-
const char *const *safe_argv = special_case ? empty_argv : argv;
|
|
116
|
-
if (special_case) {
|
|
117
|
-
argc = 1;
|
|
118
|
-
}
|
|
119
114
|
|
|
120
115
|
auto argv_size = static_cast<size_t>(argc);
|
|
121
116
|
// SetArgv* on python 3 takes wchar_t, so we have to convert.
|
|
@@ -123,7 +118,7 @@ inline void initialize_interpreter_pre_pyconfig(bool init_signal_handlers,
|
|
|
123
118
|
std::vector<std::unique_ptr<wchar_t[], detail::wide_char_arg_deleter>> widened_argv_entries;
|
|
124
119
|
widened_argv_entries.reserve(argv_size);
|
|
125
120
|
for (size_t ii = 0; ii < argv_size; ++ii) {
|
|
126
|
-
widened_argv_entries.emplace_back(detail::widen_chars(
|
|
121
|
+
widened_argv_entries.emplace_back(detail::widen_chars(argv[ii]));
|
|
127
122
|
if (!widened_argv_entries.back()) {
|
|
128
123
|
// A null here indicates a character-encoding failure or the python
|
|
129
124
|
// interpreter out of memory. Give up.
|
|
@@ -205,6 +200,9 @@ inline void initialize_interpreter(bool init_signal_handlers = true,
|
|
|
205
200
|
config.install_signal_handlers = init_signal_handlers ? 1 : 0;
|
|
206
201
|
initialize_interpreter(&config, argc, argv, add_program_dir_to_path);
|
|
207
202
|
#endif
|
|
203
|
+
|
|
204
|
+
// There is exactly one interpreter alive currently.
|
|
205
|
+
detail::get_num_interpreters_seen() = 1;
|
|
208
206
|
}
|
|
209
207
|
|
|
210
208
|
/** \rst
|
|
@@ -243,26 +241,32 @@ inline void initialize_interpreter(bool init_signal_handlers = true,
|
|
|
243
241
|
|
|
244
242
|
\endrst */
|
|
245
243
|
inline void finalize_interpreter() {
|
|
246
|
-
//
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
internals_ptr_ptr = detail::get_internals_pp_from_capsule(internals_obj);
|
|
244
|
+
// get rid of any thread-local interpreter cache that currently exists
|
|
245
|
+
if (detail::get_num_interpreters_seen() > 1) {
|
|
246
|
+
detail::get_internals_pp_manager().unref();
|
|
247
|
+
detail::get_local_internals_pp_manager().unref();
|
|
248
|
+
|
|
249
|
+
// We know there can be no other interpreter alive now, so we can lower the count
|
|
250
|
+
detail::get_num_interpreters_seen() = 1;
|
|
254
251
|
}
|
|
255
|
-
|
|
256
|
-
//
|
|
257
|
-
|
|
258
|
-
|
|
252
|
+
|
|
253
|
+
// Re-fetch the internals pointer-to-pointer (but not the internals itself, which might not
|
|
254
|
+
// exist). It's possible for the internals to be created during Py_Finalize() (e.g. if a
|
|
255
|
+
// py::capsule calls `get_internals()` during destruction), so we get the pointer-pointer here
|
|
256
|
+
// and check it after Py_Finalize().
|
|
257
|
+
detail::get_internals_pp_manager().get_pp();
|
|
258
|
+
detail::get_local_internals_pp_manager().get_pp();
|
|
259
259
|
|
|
260
260
|
Py_Finalize();
|
|
261
261
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
262
|
+
detail::get_internals_pp_manager().destroy();
|
|
263
|
+
|
|
264
|
+
// Local internals contains data managed by the current interpreter, so we must clear them to
|
|
265
|
+
// avoid undefined behaviors when initializing another interpreter
|
|
266
|
+
detail::get_local_internals_pp_manager().destroy();
|
|
267
|
+
|
|
268
|
+
// We know there is no interpreter alive now, so we can reset the count
|
|
269
|
+
detail::get_num_interpreters_seen() = 0;
|
|
266
270
|
}
|
|
267
271
|
|
|
268
272
|
/** \rst
|
netgen/include/pybind11/eval.h
CHANGED
|
@@ -19,7 +19,7 @@ PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
|
|
|
19
19
|
PYBIND11_NAMESPACE_BEGIN(detail)
|
|
20
20
|
|
|
21
21
|
inline void ensure_builtins_in_globals(object &global) {
|
|
22
|
-
#if defined(PYPY_VERSION)
|
|
22
|
+
#if defined(PYPY_VERSION)
|
|
23
23
|
// Running exec and eval adds `builtins` module under `__builtins__` key to
|
|
24
24
|
// globals if not yet present. Python 3.8 made PyRun_String behave
|
|
25
25
|
// similarly. Let's also do that for older versions, for consistency. This
|
|
@@ -94,18 +94,18 @@ void exec(const char (&s)[N], object global = globals(), object local = object()
|
|
|
94
94
|
eval<eval_statements>(s, std::move(global), std::move(local));
|
|
95
95
|
}
|
|
96
96
|
|
|
97
|
-
#if defined(PYPY_VERSION)
|
|
97
|
+
#if defined(PYPY_VERSION) || defined(GRAALVM_PYTHON)
|
|
98
98
|
template <eval_mode mode = eval_statements>
|
|
99
99
|
object eval_file(str, object, object) {
|
|
100
|
-
pybind11_fail("eval_file not supported in
|
|
100
|
+
pybind11_fail("eval_file not supported in this interpreter. Use eval");
|
|
101
101
|
}
|
|
102
102
|
template <eval_mode mode = eval_statements>
|
|
103
103
|
object eval_file(str, object) {
|
|
104
|
-
pybind11_fail("eval_file not supported in
|
|
104
|
+
pybind11_fail("eval_file not supported in this interpreter. Use eval");
|
|
105
105
|
}
|
|
106
106
|
template <eval_mode mode = eval_statements>
|
|
107
107
|
object eval_file(str) {
|
|
108
|
-
pybind11_fail("eval_file not supported in
|
|
108
|
+
pybind11_fail("eval_file not supported in this interpreter. Use eval");
|
|
109
109
|
}
|
|
110
110
|
#else
|
|
111
111
|
template <eval_mode mode = eval_statements>
|
|
@@ -133,7 +133,12 @@ object eval_file(str fname, object global = globals(), object local = object())
|
|
|
133
133
|
|
|
134
134
|
int closeFile = 1;
|
|
135
135
|
std::string fname_str = (std::string) fname;
|
|
136
|
-
FILE *f =
|
|
136
|
+
FILE *f =
|
|
137
|
+
# if PY_VERSION_HEX >= 0x030E0000
|
|
138
|
+
Py_fopen(fname.ptr(), "r");
|
|
139
|
+
# else
|
|
140
|
+
_Py_fopen_obj(fname.ptr(), "r");
|
|
141
|
+
# endif
|
|
137
142
|
if (!f) {
|
|
138
143
|
PyErr_Clear();
|
|
139
144
|
pybind11_fail("File \"" + fname_str + "\" could not be opened!");
|
|
@@ -15,6 +15,47 @@
|
|
|
15
15
|
|
|
16
16
|
PYBIND11_NAMESPACE_BEGIN(PYBIND11_NAMESPACE)
|
|
17
17
|
PYBIND11_NAMESPACE_BEGIN(detail)
|
|
18
|
+
PYBIND11_NAMESPACE_BEGIN(type_caster_std_function_specializations)
|
|
19
|
+
|
|
20
|
+
// ensure GIL is held during functor destruction
|
|
21
|
+
struct func_handle {
|
|
22
|
+
function f;
|
|
23
|
+
#if !(defined(_MSC_VER) && _MSC_VER == 1916 && defined(PYBIND11_CPP17))
|
|
24
|
+
// This triggers a syntax error under very special conditions (very weird indeed).
|
|
25
|
+
explicit
|
|
26
|
+
#endif
|
|
27
|
+
func_handle(function &&f_) noexcept
|
|
28
|
+
: f(std::move(f_)) {
|
|
29
|
+
}
|
|
30
|
+
func_handle(const func_handle &f_) { operator=(f_); }
|
|
31
|
+
func_handle &operator=(const func_handle &f_) {
|
|
32
|
+
gil_scoped_acquire acq;
|
|
33
|
+
f = f_.f;
|
|
34
|
+
return *this;
|
|
35
|
+
}
|
|
36
|
+
~func_handle() {
|
|
37
|
+
gil_scoped_acquire acq;
|
|
38
|
+
function kill_f(std::move(f));
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// to emulate 'move initialization capture' in C++11
|
|
43
|
+
struct func_wrapper_base {
|
|
44
|
+
func_handle hfunc;
|
|
45
|
+
explicit func_wrapper_base(func_handle &&hf) noexcept : hfunc(hf) {}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
template <typename Return, typename... Args>
|
|
49
|
+
struct func_wrapper : func_wrapper_base {
|
|
50
|
+
using func_wrapper_base::func_wrapper_base;
|
|
51
|
+
Return operator()(Args... args) const { // NOLINT(performance-unnecessary-value-param)
|
|
52
|
+
gil_scoped_acquire acq;
|
|
53
|
+
// casts the returned object as a rvalue to the return type
|
|
54
|
+
return hfunc.f(std::forward<Args>(args)...).template cast<Return>();
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
PYBIND11_NAMESPACE_END(type_caster_std_function_specializations)
|
|
18
59
|
|
|
19
60
|
template <typename Return, typename... Args>
|
|
20
61
|
struct type_caster<std::function<Return(Args...)>> {
|
|
@@ -50,23 +91,22 @@ public:
|
|
|
50
91
|
auto *cfunc_self = PyCFunction_GET_SELF(cfunc.ptr());
|
|
51
92
|
if (cfunc_self == nullptr) {
|
|
52
93
|
PyErr_Clear();
|
|
53
|
-
} else
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
function_record *rec = nullptr;
|
|
57
|
-
// Check that we can safely reinterpret the capsule into a function_record
|
|
58
|
-
if (detail::is_function_record_capsule(c)) {
|
|
59
|
-
rec = c.get_pointer<function_record>();
|
|
60
|
-
}
|
|
61
|
-
|
|
94
|
+
} else {
|
|
95
|
+
function_record *rec = function_record_ptr_from_PyObject(cfunc_self);
|
|
62
96
|
while (rec != nullptr) {
|
|
63
97
|
if (rec->is_stateless
|
|
64
98
|
&& same_type(typeid(function_type),
|
|
65
99
|
*reinterpret_cast<const std::type_info *>(rec->data[1]))) {
|
|
66
100
|
struct capture {
|
|
67
101
|
function_type f;
|
|
102
|
+
|
|
103
|
+
static capture *from_data(void **data) {
|
|
104
|
+
return PYBIND11_STD_LAUNDER(reinterpret_cast<capture *>(data));
|
|
105
|
+
}
|
|
68
106
|
};
|
|
69
|
-
|
|
107
|
+
PYBIND11_ENSURE_PRECONDITION_FOR_FUNCTIONAL_H_PERFORMANCE_OPTIMIZATIONS(
|
|
108
|
+
std::is_standard_layout<capture>::value);
|
|
109
|
+
value = capture::from_data(rec->data)->f;
|
|
70
110
|
return true;
|
|
71
111
|
}
|
|
72
112
|
rec = rec->next;
|
|
@@ -77,40 +117,8 @@ public:
|
|
|
77
117
|
// See PR #1413 for full details
|
|
78
118
|
}
|
|
79
119
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
function f;
|
|
83
|
-
#if !(defined(_MSC_VER) && _MSC_VER == 1916 && defined(PYBIND11_CPP17))
|
|
84
|
-
// This triggers a syntax error under very special conditions (very weird indeed).
|
|
85
|
-
explicit
|
|
86
|
-
#endif
|
|
87
|
-
func_handle(function &&f_) noexcept
|
|
88
|
-
: f(std::move(f_)) {
|
|
89
|
-
}
|
|
90
|
-
func_handle(const func_handle &f_) { operator=(f_); }
|
|
91
|
-
func_handle &operator=(const func_handle &f_) {
|
|
92
|
-
gil_scoped_acquire acq;
|
|
93
|
-
f = f_.f;
|
|
94
|
-
return *this;
|
|
95
|
-
}
|
|
96
|
-
~func_handle() {
|
|
97
|
-
gil_scoped_acquire acq;
|
|
98
|
-
function kill_f(std::move(f));
|
|
99
|
-
}
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
// to emulate 'move initialization capture' in C++11
|
|
103
|
-
struct func_wrapper {
|
|
104
|
-
func_handle hfunc;
|
|
105
|
-
explicit func_wrapper(func_handle &&hf) noexcept : hfunc(std::move(hf)) {}
|
|
106
|
-
Return operator()(Args... args) const {
|
|
107
|
-
gil_scoped_acquire acq;
|
|
108
|
-
// casts the returned object as a rvalue to the return type
|
|
109
|
-
return hfunc.f(std::forward<Args>(args)...).template cast<Return>();
|
|
110
|
-
}
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
value = func_wrapper(func_handle(std::move(func)));
|
|
120
|
+
value = type_caster_std_function_specializations::func_wrapper<Return, Args...>(
|
|
121
|
+
type_caster_std_function_specializations::func_handle(std::move(func)));
|
|
114
122
|
return true;
|
|
115
123
|
}
|
|
116
124
|
|
|
@@ -127,11 +135,12 @@ public:
|
|
|
127
135
|
return cpp_function(std::forward<Func>(f_), policy).release();
|
|
128
136
|
}
|
|
129
137
|
|
|
130
|
-
PYBIND11_TYPE_CASTER(
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
138
|
+
PYBIND11_TYPE_CASTER(
|
|
139
|
+
type,
|
|
140
|
+
const_name("collections.abc.Callable[[")
|
|
141
|
+
+ ::pybind11::detail::concat(::pybind11::detail::arg_descr(make_caster<Args>::name)...)
|
|
142
|
+
+ const_name("], ") + ::pybind11::detail::return_descr(make_caster<retval_type>::name)
|
|
143
|
+
+ const_name("]"));
|
|
135
144
|
};
|
|
136
145
|
|
|
137
146
|
PYBIND11_NAMESPACE_END(detail)
|