Skip to content

Support for pyproj: cpython.pythread APIs cause runtime crash #590

@shrynx

Description

@shrynx

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.

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