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
- Extract
spatial_graph/_rtree/ into a standalone package (rtree-nd).
- Build-time codegen + cibuildwheel → binary wheels for the
enumerated combos across all platforms / supported CPythons.
- Drop the runtime
witty fallback by default; optionally expose it behind a
[jit] extra for strange dtype combinations.
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).
spatial_graph's R-tree is currently JIT-compiled at runtime via
witty: the first time aPointRTree/LineRTreeis instantiated for a given dtype combination,RTree.__init__callswitty.compile_cython, which invokes the system Ccompiler and caches the resulting extension module
(
_rtree/rtree.py:45-62).Because
motile_trackerdepends ontracksdatawhich depends onspatial_graph,every end user of
motile_trackerneeds 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
wittyat runtime.Recommended plan
spatial_graph/_rtree/into a standalone package (rtree-nd).enumerated combos across all platforms / supported CPythons.
wittyfallback by default; optionally expose it behind a[jit]extra for strange dtype combinations.spatial_graphdepends onrtree-nd;tracksdatacan depend onrtree-nddirectly for
BBoxSpatialFilter(it does not need the rest ofspatial_graph's graph machinery).