Rebase custom patches onto upstream v0.8.0 (NumPy 2 support) - #1
Conversation
Main C++ code should be able to drive memory management of armadillo even for independent compilation units (i.e. not header only)
Verified against numpy 1.26.4 and 2.5.1 headers: PyArray_CopyInto's slot in the _ARRAY_API table moved from 82 to 50, while every other function carma uses kept its offset. The upstream numpy2 fix (4c966bf) hardcoded the new index unconditionally, which silently calls the wrong C function when loaded under NumPy 1.x. Pick the index at runtime from numpy.__version__.
|
Found and fixed a real bug in the upstream numpy2 fix (4c966bf) while testing this against both NumPy versions: `PyArray_CopyInto`'s slot in the `_ARRAY_API` table moved from 82 (NumPy 1.x) to 50 (NumPy 2.x), confirmed empirically against the two headers. The upstream fix hardcoded 50 unconditionally, meaning this would silently call the wrong C function under NumPy 1.x (undefined behavior, not a clean crash). Added a runtime check on `numpy.version` to pick the right index. Verified locally: built once, tested the same `.so` against NumPy 1.26.4 and NumPy 2.5.1 — both take the `PyArray_CopyInto` code path correctly (non-Fortran-contiguous predict input) and return correct results. Full pylibkriging test suite (83 tests, excluding 2 unrelated pre-existing sklearn-wrapper failures) passes against NumPy 2.5.1 with this branch + pybind11 2.13.6. |
ubuntu-latest and windows-latest moved to newer default images (ubuntu-24.04, windows-2025) that no longer ship clang-14/gcc-11 or the hardcoded VS2022 Enterprise path this workflow expects. Pin to ubuntu-22.04 and windows-2022, which still provide them, to restore what these jobs were originally testing.
# Conflicts: # cmake/ClearOptions.cmake
libKriging/carma#1 got merged into v0.6.6-custom (the branch this submodule actually tracks, despite .gitmodules saying 'stable' - that metadata was already stale before this change). Point at the merge commit instead of the now-orphaned PR branch tip.
Summary
stablebranch (based on upstream v0.6.6) onto upstreamv0.8.0.4c966bf, "CHG: Make vendored Numpy api compatable with Numpy v2"):_ARRAY_APItable offset forPyArray_CopyInto(82 → 50), which changed between NumPy 1.x and 2.x.pybind11::detail::import_numpy_core_submodule, needed because NumPy 2.0 movednumpy.coretonumpy._core. Requires pybind11 >= 2.12.0.Do not unset global CMake variables(conflict: upstream had already gated theCMAKE_INSTALL_PREFIXunset behindCARMA_DEV_MODE; kept that and additionally commented out theCMAKE_EXPORT_COMPILE_COMMANDSreset per our original intent)Customize: add a smooth policy using macro to drive carma mem functionsExplicity namespace for ssize_t in pybind11Context
This is part of upgrading libKriging's Python bindings (pylibkriging) to drop the
numpy<2pin, which currently exists because our vendored carma (v0.6.6) hardcodes NumPy C-API table offsets that changed in NumPy 2.0.Test plan