Skip to content

Import failure on macOS 26 due to WX memory restrictions #404 #151

@DanielO

Description

@DanielO

What happened?

On Tahoe (at least on ARM hardware) macOS refuses allocations for writeable+executable memory unless the process has a specific entitlement.

While this is not an eccodes bug per se I imagine more people will run into its time goes on.
I would like to say I found an easy work around but thus far I have been unable to grant the entitlement locally.
I think one work around would be to write a small C stub to handle the callback, obviously this is rather annoying though.

What are the steps to reproduce the bug?

Install Python 3.13 and py313-eccodes from macports.
Run python3.13 -c "import eccodes"

Version

v2.44.0

Platform (OS and architecture)

Darwin Havok.gsoft.com.au 25.2.0 Darwin Kernel Version 25.2.0: Tue Nov 18 21:09:49 PST 2025; root:xnu-12377.61.12~1/RELEASE_ARM64_T8142 arm64

Relevant log output

----> 1 import eccodes

File /opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/eccodes/__init__.py:14
      1 #
      2 # (C) Copyright 2017- ECMWF.
      3 #
   (...)
     10 #
     11 #
     13 from .eccodes import *  # noqa
---> 14 from .highlevel import *  # noqa

File /opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/eccodes/highlevel/__init__.py:2
      1 from .message import GRIBMessage, Message  # noqa
----> 2 from .reader import FileReader, MemoryReader, StreamReader  # noqa

File /opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/eccodes/highlevel/reader.py:76
     72         self.buf = None
     73         return handle
---> 76 @ffi.callback("long(*)(void*, void*, long)")
     77 def pyread_callback(payload, buf, length):
     78     stream = ffi.from_handle(payload)
     79     read = stream.read(length)

File /opt/local/Library/Frameworks/Python.framework/Versions/3.13/lib/python3.13/site-packages/cffi/api.py:396, in FFI.callback.<locals>.callback_decorator_wrap(python_callable)
    393 if not callable(python_callable):
    394     raise TypeError("the 'python_callable' argument "
    395                     "is not callable")
--> 396 return self._backend.callback(cdecl, python_callable,
    397                               error, onerror)

MemoryError: Cannot allocate write+execute memory for ffi.callback(). You might be running on a system that prevents this. For more information, see https://cffi.readthedocs.io/en/latest/using.html#callbacks

Accompanying data

No response

Organisation

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions