graalpython icon indicating copy to clipboard operation
graalpython copied to clipboard

Support for pyproj: cpython.pythread APIs cause runtime crash

Open shrynx opened this issue 3 months ago • 0 comments

Summary

pyproj builds successfully on GraalPy but crashes at runtime with SystemError: internal exception occurred due to unsupported cpython.pythread Cython APIs.

Environment

  • GraalPy 25.0.0 (Python 3.12.8), macOS ARM64
  • pyproj 3.7.2, PROJ 9.7.1

Reproduction

graalpy -m venv .venv && source .venv/bin/activate
PROJ_DIR=/path/to/proj pip install pyproj
python -c "from pyproj import CRS"  # crashes
Error

File "pyproj/_crs.pyx", line 22, in init pyproj._crs
SystemError: internal exception occurred

Root Cause

pyproj's _context.pyx uses CPython thread-local storage APIs:

from cpython.pythread cimport PyThread_tss_create, PyThread_tss_get, PyThread_tss_set These are used unconditionally (no fallback for non-CPython implementations).

What I Tried

Patched _compat.pyx to remove cpython cimport array, this worked But _context.pyx still crashes due to the cpython.pythread imports above

Suggested Fix

Either:

  • GraalPy patches for pyproj (similar to numpy/pandas patches)
  • Implement cpython.pythread APIs: PyThread_tss_create, PyThread_tss_get, PyThread_tss_set

Impact

pyproj is required by geopandas and the broader geospatial Python ecosystem.

shrynx avatar Jan 13 '26 20:01 shrynx