Skip to content

Extract the R-tree into a standalone, prebuilt-wheel package #56

Description

@cmalinmayor

spatial_graph's R-tree is currently JIT-compiled at runtime via witty: the first time a
PointRTree/LineRTree is instantiated for a given dtype combination,
RTree.__init__ calls witty.compile_cython, which invokes the system C
compiler and caches the resulting extension module
(_rtree/rtree.py:45-62).

Because motile_tracker depends on tracksdata which depends on spatial_graph,
every end user of motile_tracker needs a working C compiler installed. 😭
This is already causing issues with our Windows-based users.

The rest of spatial_graph JIT-compiles because graph attribute dtypes are
genuinely unknowable until runtime. The R-tree is different: it only ever
stores a node/edge id plus a bounding box, so its compile parameters come from
a small, enumerable set. It can be prebuilt and shipped as a standalone package with precompiled binary wheels so
that common dtype combinations require no compiler and no witty at runtime.

Recommended plan

  1. Extract spatial_graph/_rtree/ into a standalone package (rtree-nd).
  2. Build-time codegen + cibuildwheel → binary wheels for the
    enumerated combos across all platforms / supported CPythons.
  3. Drop the runtime witty fallback by default; optionally expose it behind a
    [jit] extra for strange dtype combinations.
  4. spatial_graph depends on rtree-nd; tracksdata can depend on rtree-nd
    directly for BBoxSpatialFilter (it does not need the rest of
    spatial_graph's graph machinery).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions