Skip to content

Commit

Permalink
[legacy] boost: Backport support for Numpy 2
Browse files Browse the repository at this point in the history
  • Loading branch information
dennisklein committed Aug 15, 2024
1 parent ba8c14a commit f7eb6ab
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmake/legacy.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,7 @@ ExternalProject_Add(boost
URL "https://boostorg.jfrog.io/artifactory/main/release/1.${boost_version}.0/source/boost_1_${boost_version}_0.tar.bz2"
URL_HASH SHA256=6478edfe2f3305127cffe8caf73ea0176c53769f4bf1585be237eb30798c3b8e
BUILD_IN_SOURCE ON
PATCH_COMMAND ${patch} -d libs/python -p1 -i "${CMAKE_SOURCE_DIR}/legacy/boost/support-numpy-2.patch"
CONFIGURE_COMMAND "./bootstrap.sh"
"--prefix=${CMAKE_INSTALL_PREFIX}"
${boost_python_config_bootstrap}
Expand Down
28 changes: 28 additions & 0 deletions legacy/boost/support-numpy-2.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
From 33ac06ca59a68266d3d26edf08205d31ddab4a6c Mon Sep 17 00:00:00 2001
From: Alexis DUBURCQ <[email protected]>
Date: Fri, 15 Mar 2024 14:10:16 +0100
Subject: [PATCH] Support numpy 2.0.0b1

---
src/numpy/dtype.cpp | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/numpy/dtype.cpp b/src/numpy/dtype.cpp
index 88a20a27b5..da30d1927b 100644
--- a/src/numpy/dtype.cpp
+++ b/src/numpy/dtype.cpp
@@ -98,7 +98,13 @@ python::detail::new_reference dtype::convert(object const & arg, bool align)
return python::detail::new_reference(reinterpret_cast<PyObject*>(obj));
}

-int dtype::get_itemsize() const { return reinterpret_cast<PyArray_Descr*>(ptr())->elsize;}
+int dtype::get_itemsize() const {
+#if NPY_ABI_VERSION < 0x02000000
+ return reinterpret_cast<PyArray_Descr*>(ptr())->elsize;
+#else
+ return PyDataType_ELSIZE(reinterpret_cast<PyArray_Descr*>(ptr()));
+#endif
+}

bool equivalent(dtype const & a, dtype const & b) {
// On Windows x64, the behaviour described on

0 comments on commit f7eb6ab

Please sign in to comment.