From 85c9c3f7d9194aa22381d95f2f4ff5d7408cfeb2 Mon Sep 17 00:00:00 2001
From: John McQuah <jmcquah@disroot.org>
Date: Sat, 20 Jul 2024 04:57:36 +0000
Subject: [PATCH] boost: fix build when python3-numpy is installed

closes #16
---
 boost/.signature                        |  5 +++--
 boost/Pkgfile                           |  2 ++
 boost/boost-1.85.0-python-numpy-2.patch | 26 +++++++++++++++++++++++++
 3 files changed, 31 insertions(+), 2 deletions(-)
 create mode 100644 boost/boost-1.85.0-python-numpy-2.patch

diff --git a/boost/.signature b/boost/.signature
index 079861758..45e93d408 100644
--- a/boost/.signature
+++ b/boost/.signature
@@ -1,6 +1,7 @@
 untrusted comment: verify with /etc/ports/contrib.pub
-RWSagIOpLGJF33tLcIUzGwZFEMSMhOjqRl8ACdOO8lCMDvO0BNyKXCo4mZqfdzFX6rWgvyKR/Pl/N8QEYpDGNwiWQX7cbxkeOgA=
-SHA256 (Pkgfile) = c5dac9de90574256daa9ed15f0c6d6b2fcfbfe4ef58ddb1c9432e96fd16c70f4
+RWSagIOpLGJF39HE80zCm5PEvItXm3MANTWeBgYTQOXKW2iy1qPoX6Hov+6kr/Vqefsh6eNSHH3wynl+c6flk8sMCEndPngDXwo=
+SHA256 (Pkgfile) = a7b1d9aa98c84b6e02c3a1de295b3a3ccc9bb286b48884234daae7fa71f92794
 SHA256 (.footprint) = 2f2e531b94ded51de4e68195b53ae53000b6fd24fdb7b51ea9e5b01d4ad36e9b
 SHA256 (boost_1_85_0.tar.bz2) = 7009fe1faa1697476bdc7027703a2badb84e849b7b0baad5086b087b971f8617
+SHA256 (boost-1.85.0-python-numpy-2.patch) = 39221b050c25993d05be1419cece8524f94755b9bdff3405fe0ac89f2eba4541
 SHA256 (boost-ublas-c++20-iterator.patch) = aa38addb40d5f44b4a8472029b475e7e6aef1c460509eb7d8edf03491dc1b5ee
diff --git a/boost/Pkgfile b/boost/Pkgfile
index f01bfebca..79327bafb 100644
--- a/boost/Pkgfile
+++ b/boost/Pkgfile
@@ -8,6 +8,7 @@ name=boost
 version=1.85.0
 release=1
 source=(https://boostorg.jfrog.io/artifactory/main/release/$version/source/${name}_${version//./_}.tar.bz2
+  boost-1.85.0-python-numpy-2.patch
   boost-ublas-c++20-iterator.patch)
 
 build() {
@@ -15,6 +16,7 @@ build() {
 
   # https://github.com/boostorg/ublas/pull/97
   patch -p2 -i $SRC/boost-ublas-c++20-iterator.patch
+  prt-get isinst python3-numpy && patch -p1 -i $SRC/boost-1.85.0-python-numpy-2.patch
 
   # https://github.com/boostorg/phoenix/issues/111
   sed -e '/^\s*auto uarg/s/auto/const auto/' \
diff --git a/boost/boost-1.85.0-python-numpy-2.patch b/boost/boost-1.85.0-python-numpy-2.patch
new file mode 100644
index 000000000..e7a7d98b8
--- /dev/null
+++ b/boost/boost-1.85.0-python-numpy-2.patch
@@ -0,0 +1,26 @@
+https://bugs.gentoo.org/932459
+https://github.com/boostorg/python/issues/431
+https://github.com/boostorg/python/pull/432
+
+From 33ac06ca59a68266d3d26edf08205d31ddab4a6c Mon Sep 17 00:00:00 2001
+From: Alexis DUBURCQ <alexis.duburcq@gmail.com>
+Date: Fri, 15 Mar 2024 14:10:16 +0100
+Subject: [PATCH] Support numpy 2.0.0b1
+
+--- a/libs/python/src/numpy/dtype.cpp
++++ b/libs/python/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