Phase 10A/10B Inc 0: build system, handle model, first module surface
Builds n3xd-ocp end to end and publishes 7.9.3.1.dev1 to the Gitea registry, where it installs anonymously and passes its suite. - occt/Dockerfile: OCCT 7.9.3 compiled once into a manylinux_2_28 builder image (base digest + tarball sha256 pinned), Draw/VTK/Tk/Xlib/OpenGL off, FreeType on, -O2 without fast-math or march=native. A final layer asserts TKService/TKV3d exist with no libGL/libX11 DT_NEEDED, which is what lets the app image drop libgl1/libx11-6. Mounted into, never built FROM. - scikit-build-core + nanobind STABLE_ABI -> one cp312-abi3 extension that registers every OCP.* submodule via PyImport_AddModule, so `import OCP.TopoDS` needs no shim and cls.__module__ is right. Version <occt>.N is asserted against the OCCT found, keeping occt_version() truthful. - occt_handle.h: type caster for opencascade::handle<T> over OCCT's intrusive refcount. Wrappers are non-owning instances holding exactly one handle in their keep-alive list, reusing an existing wrapper so identity survives a round trip. Transient constructors go through ocp_new (never nb::init<>, which would let OCCT delete nanobind's storage); the caster refuses a refcount-0 object rather than corrupt the heap. Verified under ASAN with no memory-safety errors, plus an RSS bound over 50k create/destroy cycles. - Sub-shapes are returned by value everywhere, making the TShape lifetime class that segfaulted a process-global face memo unrepresentable. - Standard_Failure derives RuntimeError, with ~20 concrete types dispatched on the dynamic OCCT type (cad_pool marshals failures home by type name). - Inc 0 surface: gp subset, TopAbs, TopoDS (+ downcasts), TopExp, TopLoc, TopTools, BRep, BinTools, Poly, Standard. 34 of the app's 139 symbols. - n3xd_ocp: additive APIs kept out of the OCP namespace so parity testing stays meaningful. bintools (shape <-> bytes, GIL-free, byte-identical) and _debug. Two findings worth the record, both verified against the stock wheel rather than assumed: upstream binds __hash__ but leaves __eq__ at identity, which is exactly what geom_memo.py's hash-bucket + IsSame scan is built around, so we match it instead of "fixing" it; and BinTools can release the GIL after all, by slurping the file-like object instead of bridging a streambuf that would call back into Python. Gate: BREP round-trips are byte-identical to cadquery-ocp-novtk across six fixtures (the generator asserts stock idempotency first). That matters beyond IPC — derive.py content-addresses BREP payloads by sha256 and stores the ref.
This commit is contained in:
25
python/OCP/__init__.py
Normal file
25
python/OCP/__init__.py
Normal file
@@ -0,0 +1,25 @@
|
||||
"""OCP — Python bindings for the OpenCASCADE (OCCT) geometry kernel.
|
||||
|
||||
Installs under the same import path as ``cadquery-ocp``/``cadquery-ocp-novtk``
|
||||
so it is a drop-in replacement; the two can never be installed together, and a
|
||||
process can only ever hold one OCCT build.
|
||||
|
||||
The compiled extension registers every ``OCP.*`` submodule directly in
|
||||
``sys.modules``, so ``import OCP.TopoDS`` works without a shim module per name.
|
||||
This file only re-exports them as attributes, so ``OCP.TopoDS`` also resolves
|
||||
after a bare ``import OCP``.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
|
||||
from . import _OCP
|
||||
|
||||
__version__ = _OCP.__version__
|
||||
__occt_version__ = _OCP.__occt_version__
|
||||
|
||||
for _name in _OCP.__all_modules__:
|
||||
setattr(sys.modules[__name__], _name, sys.modules[f"OCP.{_name}"])
|
||||
|
||||
__all__ = [*_OCP.__all_modules__, "__version__", "__occt_version__"]
|
||||
0
python/OCP/py.typed
Normal file
0
python/OCP/py.typed
Normal file
21
python/n3xd_ocp/__init__.py
Normal file
21
python/n3xd_ocp/__init__.py
Normal file
@@ -0,0 +1,21 @@
|
||||
"""n3xd_ocp — performance APIs that go beyond the upstream OCP surface.
|
||||
|
||||
Kept separate from ``OCP`` on purpose: that namespace stays a symbol-for-symbol
|
||||
drop-in for ``cadquery-ocp-novtk`` so parity testing means something, while
|
||||
anything additive lives here. Shipped in the same wheel, backed by the same
|
||||
OCCT build, and safe to mix with ``OCP`` objects in one process.
|
||||
|
||||
Submodules are registered by the compiled extension; importing ``OCP`` is what
|
||||
loads it.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sys
|
||||
|
||||
import OCP as _OCP_pkg # noqa: F401 (loads the extension, registering us)
|
||||
|
||||
bintools = sys.modules["n3xd_ocp.bintools"]
|
||||
_debug = sys.modules["n3xd_ocp._debug"]
|
||||
|
||||
__all__ = ["bintools"]
|
||||
0
python/n3xd_ocp/py.typed
Normal file
0
python/n3xd_ocp/py.typed
Normal file
Reference in New Issue
Block a user