Control: tags -1 + patch

The build system is looking at the old (numpy 1.x) location for the include files. The attached patch asks numpy directly where its include file is located and so is portable across versions and installation methods. An alternative is to use `/usr/bin/numpy-config --cflags` or the pkgconf numpy.pc that is shipped in python3-numpy; these won't work with older numpy that don't carry the relevant machinery.

With that, there are other build failures due to a missing include and a change in the numpy 2.x API - additional patches for them attached.

(these are not tested beyond "it builds" and the superficial autopkgtest test)

enjoy
Stuart



--
Stuart Prescott   http://www.nanonanonano.net/ stu...@nanonanonano.net
Debian Developer  http://www.debian.org/       stu...@debian.org
GPG fingerprint   90E2 D2C1 AD14 6A1B 7EBB 891D BBC1 7EBB 1396 F2F7
From a5ba07ce6f916ce1755b6ce2503e0d9c6927de7b Mon Sep 17 00:00:00 2001
From: Stuart Prescott <stu...@debian.org>
Date: Wed, 5 Feb 2025 01:19:48 +1100
Subject: [PATCH 1/4] Fix numpy include directory in build

---
 debian/platform_specific.mk.debian.gfortran-13 | 5 +++--
 debian/platform_specific.mk.debian.gfortran-14 | 5 +++--
 2 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/debian/platform_specific.mk.debian.gfortran-13 b/debian/platform_specific.mk.debian.gfortran-13
index d0602b0..805a2d3 100644
--- a/debian/platform_specific.mk.debian.gfortran-13
+++ b/debian/platform_specific.mk.debian.gfortran-13
@@ -34,8 +34,10 @@ endif
 #
 # Local defines
 #
+	NUMPYINCDIR = $(shell python3 -c "import numpy; print(numpy.get_include())")
+
 	MYINCLUDES	= -I$(PYTHONINCDIR) \
-			  -I/usr/lib/python3/dist-packages/numpy/core/include \
+			  -I$(NUMPYINCDIR) \
 			  -I$(DIR_PREFIX)/fer/common \
 			  -I$(DIR_PREFIX)/fer/grdel \
 			  -I$(DIR_PREFIX)/fer/cferbind \
@@ -50,7 +52,6 @@ endif
 			  -I/usr/include/harfbuzz \
 			  -I/usr/include/glib-2.0 \
                           -I/usr/lib/$(BUILDARCH)/glib-2.0/include \
-			  -I/usr/lib/python3/dist-packages/numpy/core \
 			  -I/usr/include
 
 	MYDEFINES	= -Dcrptd_cat_argument \
diff --git a/debian/platform_specific.mk.debian.gfortran-14 b/debian/platform_specific.mk.debian.gfortran-14
index d0602b0..805a2d3 100644
--- a/debian/platform_specific.mk.debian.gfortran-14
+++ b/debian/platform_specific.mk.debian.gfortran-14
@@ -34,8 +34,10 @@ endif
 #
 # Local defines
 #
+	NUMPYINCDIR = $(shell python3 -c "import numpy; print(numpy.get_include())")
+
 	MYINCLUDES	= -I$(PYTHONINCDIR) \
-			  -I/usr/lib/python3/dist-packages/numpy/core/include \
+			  -I$(NUMPYINCDIR) \
 			  -I$(DIR_PREFIX)/fer/common \
 			  -I$(DIR_PREFIX)/fer/grdel \
 			  -I$(DIR_PREFIX)/fer/cferbind \
@@ -50,7 +52,6 @@ endif
 			  -I/usr/include/harfbuzz \
 			  -I/usr/include/glib-2.0 \
                           -I/usr/lib/$(BUILDARCH)/glib-2.0/include \
-			  -I/usr/lib/python3/dist-packages/numpy/core \
 			  -I/usr/include
 
 	MYDEFINES	= -Dcrptd_cat_argument \
-- 
2.39.5

From 0287f2752b6badebf8bc9d17779b05107d6bf890 Mon Sep 17 00:00:00 2001
From: Stuart Prescott <stu...@debian.org>
Date: Wed, 5 Feb 2025 01:20:17 +1100
Subject: [PATCH 2/4] Add missing include of setjmp.h

---
 debian/patches/series       |  1 +
 debian/patches/setjmp.patch | 10 ++++++++++
 2 files changed, 11 insertions(+)
 create mode 100644 debian/patches/setjmp.patch

diff --git a/debian/patches/series b/debian/patches/series
index dd4d663..cd917df 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -8,3 +8,4 @@ python3.8.diff
 gcc10.patch
 setuptools.patch
 gcc14.patch
+setjmp.patch
diff --git a/debian/patches/setjmp.patch b/debian/patches/setjmp.patch
new file mode 100644
index 0000000..1918a4b
--- /dev/null
+++ b/debian/patches/setjmp.patch
@@ -0,0 +1,10 @@
+--- a/pyfermod/libpyferret.c
++++ b/pyfermod/libpyferret.c
+@@ -41,6 +41,7 @@
+ #include <signal.h>
+ #include <stdio.h>
+ #include <stdlib.h>
++#include <setjmp.h>
+ #include <string.h>
+ 
+ #include "ferret.h"
-- 
2.39.5

From 5bba2198d280a118817ceb06499d98bd901b81ee Mon Sep 17 00:00:00 2001
From: Stuart Prescott <stu...@debian.org>
Date: Wed, 5 Feb 2025 01:20:52 +1100
Subject: [PATCH 3/4] Add patch to update for numpy 2 API

---
 debian/patches/numpy2.patch | 20 ++++++++++++++++++++
 debian/patches/series       |  1 +
 2 files changed, 21 insertions(+)
 create mode 100644 debian/patches/numpy2.patch

diff --git a/debian/patches/numpy2.patch b/debian/patches/numpy2.patch
new file mode 100644
index 0000000..b612d41
--- /dev/null
+++ b/debian/patches/numpy2.patch
@@ -0,0 +1,20 @@
+--- a/pyfermod/libpyferret.c
++++ b/pyfermod/libpyferret.c
+@@ -1414,7 +1414,7 @@
+ 
+     /* Create a new NumPy String ndarray (Fortran ordering) with the same shape */
+     strarraydescript = PyArray_DescrNewFromType(NPY_STRING);
+-    strarraydescript->elsize = maxstrlen;
++    PyDataType_SET_ELSIZE(strarraydescript, maxstrlen);
+     data_ndarray = (PyArrayObject *) PyArray_Empty(MAX_FERRET_NDIM, shape, strarraydescript, 1);
+     if ( data_ndarray == NULL ) {
+         return NULL;
+@@ -1456,7 +1456,7 @@
+     /* Create a new NumPy String ndarray with the bad-data-flag value */
+     new_shape[0] = 1;
+     strarraydescript = PyArray_DescrNewFromType(NPY_STRING);
+-    strarraydescript->elsize = maxstrlen;
++    PyDataType_SET_ELSIZE(strarraydescript, maxstrlen);
+     badval_ndarray = (PyArrayObject *) PyArray_Empty(1, new_shape, strarraydescript, 0);
+     if ( badval_ndarray == NULL ) {
+        Py_DECREF(data_ndarray);
diff --git a/debian/patches/series b/debian/patches/series
index cd917df..1e8c1db 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -9,3 +9,4 @@ gcc10.patch
 setuptools.patch
 gcc14.patch
 setjmp.patch
+numpy2.patch
-- 
2.39.5

From 3f3075e8b34fca1fd7ba00af3035c691772eb254 Mon Sep 17 00:00:00 2001
From: Stuart Prescott <stu...@debian.org>
Date: Wed, 5 Feb 2025 01:21:48 +1100
Subject: [PATCH 4/4] Update changelog

---
 debian/changelog | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index 91c8477..3a366af 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -6,6 +6,11 @@ pyferret (7.6.5-9) UNRELEASED; urgency=medium
   [ Alexandre Detiste ]
   * add explicit build-dependency on python3-setuptools (Closes: #1080708)
 
+  [ Stuart Prescott ]
+  * Fix build system to use correct location for numpy headers for numpy 2.x
+    (Closes: #1094373)
+  * Add patches to handle API changes for numpy 2.x.
+
  -- Alexandre Detiste <tc...@debian.org>  Sat, 18 Jan 2025 15:48:36 +0100
 
 pyferret (7.6.5-8) unstable; urgency=medium
-- 
2.39.5

Reply via email to