from __future__ import annotations

import sys


def ensure_numpy_pickle_compat() -> None:
    """Allow NumPy 1 environments to unpickle arrays serialized by NumPy 2.

    NumPy 2 moved array implementation modules from ``numpy.core`` to
    ``numpy._core``. When a worker running NumPy 2 returns pickled arrays to a
    BLISS process still running NumPy 1, unpickling can fail because the older
    environment does not provide the ``numpy._core`` module path.
    """
    try:
        import numpy.core as numpy_core
    except Exception:
        return

    sys.modules.setdefault("numpy._core", numpy_core)

    try:
        import numpy.core.multiarray as numpy_core_multiarray
    except Exception:
        return

    sys.modules.setdefault("numpy._core.multiarray", numpy_core_multiarray)
