Skip to main content

Nanobind wrapper for OCCT

Project description

compas_occt

Direct, lean nanobind bindings to the OpenCASCADE Technology (OCCT) 8 geometry kernel, packaged as a drop-in replacement for compas_occ.

compas_occt exposes the exact same public API as compas_occ — NURBS curves and surfaces (OCCNurbsCurve, OCCNurbsSurface), Boundary Representations (OCCBrep and its vertex/edge/loop/face components), booleans, fillet/offset/slice, STEP/IGES/STL/BREP I/O, and the COMPAS plugin factories so compas.geometry.Brep.from_box(...) returns an OCCBrep. The difference is the backend: instead of pythonocc-core, it links OCCT directly through a single compiled extension module, with no pythonocc-core dependency.

Design

  • One extension module. All OCCT-backed functions live in a single compas_occt._occt module that links OCCT exactly once. This keeps RTTI/memory consistent across the whole API (required for STEP/IGES) and is far leaner than one OCCT copy per submodule.
  • Functional backend + opaque handles. Thin C++ free functions operate on four opaque handle wrappers (Shape, GeomCurve, Geom2dCurve, GeomSurface); the Python classes hold one of these in self._native and delegate.
  • Zero-copy data transfer. Bulk coordinate data (mesh tessellation, NURBS control points, curve discretisation) crosses the C++↔Python boundary as numpy arrays that view the C++ buffer directly (no copy). numpy — not jax — is the right tool here: it is the zero-copy buffer-protocol partner for nanobind's ndarray, lightweight, and already a dependency.

Installation

pip install compas_occt

Development install (builds OCCT 8 from source on first build; cached afterwards):

git clone https://github.com/petrasvestartas/compas_occt.git
cd compas_occt
pip install --no-build-isolation -ve ".[dev]"

A C++17 compiler, CMake ≥ 3.15 and Ninja are required for the source build. On Windows, run the command from a Visual Studio "x64 Native Tools" prompt (or after calling vcvars64.bat).

Development with uv

uv gives a fast, reproducible environment. The first build downloads and compiles OCCT 8 (~30–60 min); it is then cached in external/occt, so later builds take a few minutes.

# 1. create the environment (Python >= 3.9; 3.14 is used here)
uv venv --python 3.14

# 2. install the build backend + the runtime and dev/docs dependencies
uv pip install scikit-build-core nanobind cmake ninja
uv pip install -e ".[dev,docs]" --no-build-isolation

# 3. (only to run the viewer examples) install compas_viewer and patch it for Python 3.14
uv pip install compas_viewer
python tools/patch_compas_viewer.py

# 4. run the tests, examples, or docs
uv run pytest tests/ -v
uv run mkdocs serve
uv run python docs/examples/breps/brep_booleans.py

On Windows, run the commands from a Visual Studio "x64 Native Tools" prompt (or after calling vcvars64.bat) so the MSVC toolchain and the .venv are both on PATH.

Python 3.14 note. compas_viewer 2.0.2 crashes on Python 3.14 (it reads self.__annotations__ in a dataclass, which PEP 749 no longer resolves to the class). tools/patch_compas_viewer.py applies the one-line upstream fix; it is idempotent and only needed to run the visualisation examples (the core compas_occt API does not need it).

Usage

from compas.geometry import Box, Point
from compas.geometry import Brep, NurbsCurve

# COMPAS plugin dispatch -> OCC implementation
brep = Brep.from_box(Box(1))
brep.to_step("box.step")

curve = NurbsCurve.from_points([Point(0, 0, 0), Point(3, 6, 0), Point(6, -3, 3), Point(10, 0, 0)])
print(curve.length())

Tests

pip install --no-build-isolation -ve ".[dev]"
python -m pytest tests/ -v

Documentation

Built with mkdocs (pip install -e ".[docs]", then mkdocs serve). Mirrors the compas_occ tutorial, examples, and API reference.

Issue Tracker

Please report bugs on the issue tracker.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

compas_occt-0.1.16.tar.gz (5.9 MB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

compas_occt-0.1.16-cp312-abi3-win_amd64.whl (10.4 MB view details)

Uploaded CPython 3.12+Windows x86-64

compas_occt-0.1.16-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (19.8 MB view details)

Uploaded CPython 3.12+manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

compas_occt-0.1.16-cp312-abi3-macosx_11_0_x86_64.whl (15.9 MB view details)

Uploaded CPython 3.12+macOS 11.0+ x86-64

compas_occt-0.1.16-cp312-abi3-macosx_11_0_arm64.whl (14.5 MB view details)

Uploaded CPython 3.12+macOS 11.0+ ARM64

compas_occt-0.1.16-cp311-cp311-win_amd64.whl (10.4 MB view details)

Uploaded CPython 3.11Windows x86-64

compas_occt-0.1.16-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (19.8 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

compas_occt-0.1.16-cp311-cp311-macosx_11_0_x86_64.whl (15.9 MB view details)

Uploaded CPython 3.11macOS 11.0+ x86-64

compas_occt-0.1.16-cp311-cp311-macosx_11_0_arm64.whl (14.5 MB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

compas_occt-0.1.16-cp310-cp310-win_amd64.whl (10.4 MB view details)

Uploaded CPython 3.10Windows x86-64

compas_occt-0.1.16-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (19.8 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

compas_occt-0.1.16-cp310-cp310-macosx_11_0_x86_64.whl (15.9 MB view details)

Uploaded CPython 3.10macOS 11.0+ x86-64

compas_occt-0.1.16-cp310-cp310-macosx_11_0_arm64.whl (14.5 MB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

compas_occt-0.1.16-cp39-cp39-win_amd64.whl (10.4 MB view details)

Uploaded CPython 3.9Windows x86-64

compas_occt-0.1.16-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (19.8 MB view details)

Uploaded CPython 3.9manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

compas_occt-0.1.16-cp39-cp39-macosx_11_0_x86_64.whl (15.9 MB view details)

Uploaded CPython 3.9macOS 11.0+ x86-64

compas_occt-0.1.16-cp39-cp39-macosx_11_0_arm64.whl (14.5 MB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file compas_occt-0.1.16.tar.gz.

File metadata

  • Download URL: compas_occt-0.1.16.tar.gz
  • Upload date:
  • Size: 5.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for compas_occt-0.1.16.tar.gz
Algorithm Hash digest
SHA256 0e161819b5bf2380d24d346cca7960eabb9764bf170287326fe204cece6812c1
MD5 4254b48120b4203b481276de381de7ce
BLAKE2b-256 517df94dbda98a54f70488b587d7c9682a7523e6fa6dc2722d16fdf249ee2a9f

See more details on using hashes here.

Provenance

The following attestation bundles were made for compas_occt-0.1.16.tar.gz:

Publisher: release.yml on petrasvestartas/compas_occt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compas_occt-0.1.16-cp312-abi3-win_amd64.whl.

File metadata

  • Download URL: compas_occt-0.1.16-cp312-abi3-win_amd64.whl
  • Upload date:
  • Size: 10.4 MB
  • Tags: CPython 3.12+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for compas_occt-0.1.16-cp312-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 2e6111265b14ea310e14b05f040231693f3026691d8ca53083f05c5c42bea9ff
MD5 ca9d44a282f1e8d510ee1adec31abe5c
BLAKE2b-256 e6a050407ba06471b327506655a86f4148a86ade2d3e23d4c7fbed0e4a38bf75

See more details on using hashes here.

Provenance

The following attestation bundles were made for compas_occt-0.1.16-cp312-abi3-win_amd64.whl:

Publisher: release.yml on petrasvestartas/compas_occt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compas_occt-0.1.16-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for compas_occt-0.1.16-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4ccca4753fe4e64282ef1ccbd6bed4f4ea0446c5dd40e22777d4448e8ed9c7fa
MD5 e74c8d35953dcbe304963e91b601e3a6
BLAKE2b-256 cd2f8411e7d1ea052bdfae244592df52d86cbc90810c9481587c811920df3fd7

See more details on using hashes here.

Provenance

The following attestation bundles were made for compas_occt-0.1.16-cp312-abi3-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on petrasvestartas/compas_occt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compas_occt-0.1.16-cp312-abi3-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for compas_occt-0.1.16-cp312-abi3-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 2cbd903f15b18f1eca6c8e02342839b496665d1a3f9509393ff5eeeeebd30b8a
MD5 ce8643adfee1676008f7761512dbd98d
BLAKE2b-256 b3073391be9ff760312cf5bd0b95002103efc00076c7cfa55777a4817614b24d

See more details on using hashes here.

Provenance

The following attestation bundles were made for compas_occt-0.1.16-cp312-abi3-macosx_11_0_x86_64.whl:

Publisher: release.yml on petrasvestartas/compas_occt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compas_occt-0.1.16-cp312-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for compas_occt-0.1.16-cp312-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1a621a78ad8d368ba873290411ba17d4c9deb9e9930a9ccc7559f49b51e48b0c
MD5 b3559ebca01bdd56a1f4a73e58055c7f
BLAKE2b-256 aa61f953da7c4b693a26c4332718f052d0ee435f510a01473717c0f8ca69e519

See more details on using hashes here.

Provenance

The following attestation bundles were made for compas_occt-0.1.16-cp312-abi3-macosx_11_0_arm64.whl:

Publisher: release.yml on petrasvestartas/compas_occt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compas_occt-0.1.16-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for compas_occt-0.1.16-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 16596b0eb961bab6b5fcabea56b29aabb9fd8eb9d4ec2a37424bf12083d37a87
MD5 36b658119de6b076b747eb80fe3f5d52
BLAKE2b-256 2e8ba40f1d0e1a54297c34c1d2334091f7d55b6ca1d7bca18716881f49b93aa2

See more details on using hashes here.

Provenance

The following attestation bundles were made for compas_occt-0.1.16-cp311-cp311-win_amd64.whl:

Publisher: release.yml on petrasvestartas/compas_occt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compas_occt-0.1.16-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for compas_occt-0.1.16-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 74f5b969ee646f064beb8904c6d87cbb8950d1bcee17dfbf6781134ecc3d2920
MD5 920cff91f5f23971d89014170d09bca2
BLAKE2b-256 1a7ec8ad87eb8f0f21cf024afdced77f724574a24502104cec0645719fd02b4b

See more details on using hashes here.

Provenance

The following attestation bundles were made for compas_occt-0.1.16-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on petrasvestartas/compas_occt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compas_occt-0.1.16-cp311-cp311-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for compas_occt-0.1.16-cp311-cp311-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 672ab5a5a36479d0eb802c63a7bce241e4dee817f310db5879fffd3859042b84
MD5 6aa4d290f711f504f6f03f6efe2790e6
BLAKE2b-256 45e9acc826a9391f6011abcb8483992f020a7dfeaa67033b94daae7043bc90b3

See more details on using hashes here.

Provenance

The following attestation bundles were made for compas_occt-0.1.16-cp311-cp311-macosx_11_0_x86_64.whl:

Publisher: release.yml on petrasvestartas/compas_occt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compas_occt-0.1.16-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for compas_occt-0.1.16-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5fcd6935ba6d1f373eb6bf68f8474fb2cb69a23303aef936234b1cb61bba1f8b
MD5 fe02d9cec5fbf76d842ea557aa56a673
BLAKE2b-256 3ae35747989f966485c17bbd0b3b99c85a0965b910b6375010812898ebc11072

See more details on using hashes here.

Provenance

The following attestation bundles were made for compas_occt-0.1.16-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: release.yml on petrasvestartas/compas_occt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compas_occt-0.1.16-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for compas_occt-0.1.16-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 4632c5b94a63c90efd28d3ae18c81ee7d42a14e6242f54dacf372e1d2760b52b
MD5 8dc1f7b9d18fd5d496b9d8ecb6f28a27
BLAKE2b-256 f8299f8cae4c92e8521a9241025372e10e5d17036c25b6709290b538200b271d

See more details on using hashes here.

Provenance

The following attestation bundles were made for compas_occt-0.1.16-cp310-cp310-win_amd64.whl:

Publisher: release.yml on petrasvestartas/compas_occt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compas_occt-0.1.16-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for compas_occt-0.1.16-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 6287a52d572e6b24ff8c168f59cfe2e6601e8b11963e7234fc037d5d6a3b2f5f
MD5 8ca16d7f8519cd28a2d7a2f2662992cb
BLAKE2b-256 c97966c8b159ea076c8edae33891ffebd9d61f7ec77f8599d4f91c1856fa2eaf

See more details on using hashes here.

Provenance

The following attestation bundles were made for compas_occt-0.1.16-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on petrasvestartas/compas_occt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compas_occt-0.1.16-cp310-cp310-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for compas_occt-0.1.16-cp310-cp310-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 37ac96d5a6430b6de6fb1ebfcfd53e919ed77849445f15c0958c81062635b4ae
MD5 e5d6c210c010b1f8e2ce195b6f253569
BLAKE2b-256 d258ef8661b35fe800ec101cad9e009c00bb4ccc09f370e140502b63be6764fe

See more details on using hashes here.

Provenance

The following attestation bundles were made for compas_occt-0.1.16-cp310-cp310-macosx_11_0_x86_64.whl:

Publisher: release.yml on petrasvestartas/compas_occt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compas_occt-0.1.16-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for compas_occt-0.1.16-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 84dae9dd590437818da5233ed7caa63ea709461fa6576d219e16e7e7ee681a3f
MD5 1e6fb072c2d30e6a652bd9354a1bdc9e
BLAKE2b-256 3d10c2eb02cb5916c21f8a1e381c0017881ff8e67e378a0353f5b5f21e5aa047

See more details on using hashes here.

Provenance

The following attestation bundles were made for compas_occt-0.1.16-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: release.yml on petrasvestartas/compas_occt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compas_occt-0.1.16-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: compas_occt-0.1.16-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 10.4 MB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for compas_occt-0.1.16-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 a797ef7609b9f315825dc3e5b658e0fa13c9e86c50ba9404446b2ee6406b7279
MD5 56fa698dcef94a466b37022ca1464bf4
BLAKE2b-256 241bce11b2a52c8dab47f59adff0ce0f3f72773466fa93829e1df7924227dc4b

See more details on using hashes here.

Provenance

The following attestation bundles were made for compas_occt-0.1.16-cp39-cp39-win_amd64.whl:

Publisher: release.yml on petrasvestartas/compas_occt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compas_occt-0.1.16-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for compas_occt-0.1.16-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 a9ed936aac51f08a57681f640776c451ebca34e820bc1bd8dd2aa579a95c45b3
MD5 99441e73f878d54307e2b601fc8937b5
BLAKE2b-256 af3222f7b02c7b2595de98e97325cf5bfd3bd6856d64502d471f9aac29b8b7ad

See more details on using hashes here.

Provenance

The following attestation bundles were made for compas_occt-0.1.16-cp39-cp39-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on petrasvestartas/compas_occt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compas_occt-0.1.16-cp39-cp39-macosx_11_0_x86_64.whl.

File metadata

File hashes

Hashes for compas_occt-0.1.16-cp39-cp39-macosx_11_0_x86_64.whl
Algorithm Hash digest
SHA256 abe4138329859ff4d09918bcaa84db7435b93a0244ca969a1605ce561cd64562
MD5 573498769f6937600c829a16dd4be2e5
BLAKE2b-256 18cd09f9376c390b2f31f0f774f536cfd86ea7ad95e09c84e63ba84a2d97bf18

See more details on using hashes here.

Provenance

The following attestation bundles were made for compas_occt-0.1.16-cp39-cp39-macosx_11_0_x86_64.whl:

Publisher: release.yml on petrasvestartas/compas_occt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file compas_occt-0.1.16-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for compas_occt-0.1.16-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 5ee695f2e5f1e91a7309c9a6a79207ce1effd8b216614dfa2f54b54a3afc57fd
MD5 470e28cde85efaf77ba2f974eda0efd4
BLAKE2b-256 0ea2a70224d93b34f9f79c8898399a23de2876830625d16296f9d2272b48720c

See more details on using hashes here.

Provenance

The following attestation bundles were made for compas_occt-0.1.16-cp39-cp39-macosx_11_0_arm64.whl:

Publisher: release.yml on petrasvestartas/compas_occt

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page