Skip to content

Rebase custom patches onto upstream v0.8.0 (NumPy 2 support) - #1

Merged
yannrichet merged 48 commits into
v0.6.6-customfrom
feature/numpy2-support
Aug 3, 2026
Merged

Rebase custom patches onto upstream v0.8.0 (NumPy 2 support)#1
yannrichet merged 48 commits into
v0.6.6-customfrom
feature/numpy2-support

Conversation

@yannrichet

Copy link
Copy Markdown
Member

Summary

  • Rebases the 3 custom patches from our stable branch (based on upstream v0.6.6) onto upstream v0.8.0.
  • Pulls in upstream's fix for NumPy 2.0 compatibility (4c966bf, "CHG: Make vendored Numpy api compatable with Numpy v2"):
    • Corrects the hardcoded _ARRAY_API table offset for PyArray_CopyInto (82 → 50), which changed between NumPy 1.x and 2.x.
    • Switches the multiarray import to pybind11::detail::import_numpy_core_submodule, needed because NumPy 2.0 moved numpy.core to numpy._core. Requires pybind11 >= 2.12.0.
  • Custom patches carried forward, cherry-picked cleanly except one trivial conflict already resolved upstream in the same spirit:
    • Do not unset global CMake variables (conflict: upstream had already gated the CMAKE_INSTALL_PREFIX unset behind CARMA_DEV_MODE; kept that and additionally commented out the CMAKE_EXPORT_COMPILE_COMMANDS reset per our original intent)
    • Customize: add a smooth policy using macro to drive carma mem functions
    • Explicity namespace for ssize_t in pybind11

Context

This is part of upgrading libKriging's Python bindings (pylibkriging) to drop the numpy<2 pin, which currently exists because our vendored carma (v0.6.6) hardcodes NumPy C-API table offsets that changed in NumPy 2.0.

Test plan

  • Build libKriging Python bindings against this carma branch with NumPy 2.x installed
  • Run pylibkriging test suite with NumPy 1.x and NumPy 2.x

@yannrichet

Copy link
Copy Markdown
Member Author

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.
@yannrichet
yannrichet changed the base branch from stable to v0.6.6-custom August 3, 2026 21:00
# Conflicts:
#	cmake/ClearOptions.cmake
@yannrichet
yannrichet merged commit 7594827 into v0.6.6-custom Aug 3, 2026
4 checks passed
yannrichet added a commit to libKriging/libKriging that referenced this pull request Aug 3, 2026
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants