Move to nanobind 3.1 and release 8.0.1.3
The handle caster follows nanobind 3's renamed detail API (keep_alive_cb, NB_CALL(nb_type_put), uint32_t caster flags). Bound surface unchanged per sigdiff; list iteration ~4x faster.
This commit is contained in:
+2
-2
@@ -1,5 +1,5 @@
|
||||
[build-system]
|
||||
requires = ["scikit-build-core>=0.11", "nanobind>=2.7,<3"]
|
||||
requires = ["scikit-build-core>=0.11", "nanobind>=3.1,<4"]
|
||||
build-backend = "scikit_build_core.build"
|
||||
|
||||
[project]
|
||||
@@ -9,7 +9,7 @@ name = "n3xd-ocp"
|
||||
# .devN suffix: the registry never allows republishing a version, and its
|
||||
# cleanup rule collects only the dev ones. CMake asserts the prefix matches
|
||||
# the OCCT it found.
|
||||
version = "8.0.1.2"
|
||||
version = "8.0.1.3"
|
||||
description = "nanobind bindings for the OpenCASCADE geometry kernel (drop-in OCP)"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12"
|
||||
|
||||
+4
-4
@@ -24,10 +24,10 @@ if [ ! -x "$VENV/bin/python" ]; then
|
||||
"$VENV/bin/pip" install -q --upgrade pip
|
||||
# numpy is a test dependency only: the n3xd_ocp bulk APIs hand back
|
||||
# ndarrays, so their tests need it to check the results.
|
||||
# nanobind 3 reworked the type-caster and rv_policy interfaces
|
||||
# occt_handle.h builds on, so moving to it is a deliberate bump, not
|
||||
# something a fresh cache picks up.
|
||||
"$VENV/bin/pip" install -q build "nanobind<3" scikit-build-core pytest numpy
|
||||
# occt_handle.h builds on nanobind's detail API, which moves between
|
||||
# majors, so the next one is a deliberate bump, not something a fresh
|
||||
# cache picks up.
|
||||
"$VENV/bin/pip" install -q build "nanobind>=3.1,<4" scikit-build-core pytest numpy
|
||||
fi
|
||||
PY="$VENV/bin/python"
|
||||
export PY VENV CACHE
|
||||
|
||||
@@ -44,7 +44,7 @@ NAMESPACE_BEGIN(detail)
|
||||
inline NB_NOINLINE void
|
||||
occt_handle_keep_alive(opencascade::handle<Standard_Transient> &&h,
|
||||
PyObject *o) noexcept {
|
||||
keep_alive(o, new opencascade::handle<Standard_Transient>(std::move(h)),
|
||||
keep_alive_cb(o, new opencascade::handle<Standard_Transient>(std::move(h)),
|
||||
[](void *p) noexcept {
|
||||
delete (opencascade::handle<Standard_Transient> *) p;
|
||||
});
|
||||
@@ -64,7 +64,7 @@ struct type_caster<
|
||||
"Conversion of opencascade::handle<T> requires that T is "
|
||||
"bound through nanobind's regular class mechanism.");
|
||||
|
||||
bool from_python(handle src, uint8_t flags,
|
||||
bool from_python(handle src, uint32_t flags,
|
||||
cleanup_list *cleanup) noexcept {
|
||||
// A null handle is OCCT's absent value and maps to None in both
|
||||
// directions; several APIs (BRep_Tool::Surface on a degenerate edge,
|
||||
@@ -74,7 +74,7 @@ struct type_caster<
|
||||
return true;
|
||||
}
|
||||
|
||||
flags &= ~((uint8_t) cast_flags::convert);
|
||||
flags &= ~cast_flags::convert;
|
||||
|
||||
Caster caster;
|
||||
if (!caster.from_python(src, flags, cleanup))
|
||||
@@ -106,7 +106,8 @@ struct type_caster<
|
||||
// dynamic type: BRep_Tool::Surface returning a Geom_Surface handle to
|
||||
// a plane arrives in Python as Geom_Plane when that class is bound.
|
||||
bool is_new = false;
|
||||
handle result = nb_type_put_p(&typeid(Td), &typeid(*ptr), (void *) ptr,
|
||||
handle result = NB_CALL(nb_type_put)(
|
||||
NB_CTX_C(cleanup), &typeid(Td), &typeid(*ptr), (void *) ptr,
|
||||
rv_policy::reference, cleanup, &is_new);
|
||||
|
||||
// Only a freshly created wrapper takes a reference. Attaching one per
|
||||
|
||||
Reference in New Issue
Block a user