Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
requires = [
"setuptools>=77",
"setuptools-scm>=8",
"Cython>=3.1",
# Cython 3.3.0 makes the __pyx_CyFunctionObject layout depend on the
# limited-API target (an extra func_is_coroutine field below 0x030B0000)
# without reflecting that in the name of the module its shared types live in,
# so our cp311 modules collide with any cp310 abi3 module built by the same
# Cython -- uharfbuzz >=0.56.1, via pygfx -- and whichever imports second dies
# with "Shared Cython type ... has the wrong size". Fixed in cython/cython#7916
# (unreleased at time of writing), so this skips the one bad release.
"Cython>=3.1,!=3.3.0",
"CT3>=3.3.3",
"numpy", # imported (not linked) while rendering the wrappers
]
Expand Down
15 changes: 15 additions & 0 deletions src/spatial_graph/_rtree/rtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import importlib
import sys
import warnings
from pathlib import Path
from typing import ClassVar

Expand Down Expand Up @@ -31,6 +32,20 @@ def _load_prebuilt(
module = importlib.import_module(f"{PREBUILT_PACKAGE}.{name}")
except ImportError:
return None
except TypeError as e: # pragma: no cover
# A Cython module already loaded in this process can claim the same
# shared-ABI module name as ours while disagreeing about the layout of
# the types in it, and the loser of that race is whoever imports second
# ("Shared Cython type ... has the wrong size"). Falling back to the JIT
# path costs a compiler, but beats taking the process down.
warnings.warn(
f"Could not import prebuilt {name} ({e}); compiling it instead. "
"This usually means another extension module in this process was "
"built against an incompatible Cython ABI.",
RuntimeWarning,
stacklevel=2,
)
return None
return module.RTree


Expand Down
Loading