Description: Fix build with numpy 1.x: PyDataType_SET_ELSIZE only exists in numpy 2;
 fall back to direct descr->elsize assignment for numpy 1.x so pyferret can
 build in both numpy 1.x and 2.x environments.
Author: tangxiaofeng <tangxiaofeng@kylinos.cn>
Origin: other
Forwarded: no
Last-Update: 2026-09-04

--- pyferret-7.6.5.orig/pyfermod/libpyferret.c
+++ pyferret-7.6.5/pyfermod/libpyferret.c
@@ -1414,7 +1414,11 @@ static PyObject *pyferretGetStrData(PyOb
 
     /* Create a new NumPy String ndarray (Fortran ordering) with the same shape */
     strarraydescript = PyArray_DescrNewFromType(NPY_STRING);
+#if defined(NPY_2_0_API_VERSION)
     PyDataType_SET_ELSIZE(strarraydescript,maxstrlen);
+#else
+    strarraydescript->elsize = maxstrlen;
+#endif
     data_ndarray = (PyArrayObject *) PyArray_Empty(MAX_FERRET_NDIM, shape, strarraydescript, 1);
     if ( data_ndarray == NULL ) {
         return NULL;
@@ -1456,7 +1460,11 @@ static PyObject *pyferretGetStrData(PyOb
     /* Create a new NumPy String ndarray with the bad-data-flag value */
     new_shape[0] = 1;
     strarraydescript = PyArray_DescrNewFromType(NPY_STRING);
+#if defined(NPY_2_0_API_VERSION)
     PyDataType_SET_ELSIZE(strarraydescript, maxstrlen);
+#else
+    strarraydescript->elsize = maxstrlen;
+#endif
     badval_ndarray = (PyArrayObject *) PyArray_Empty(1, new_shape, strarraydescript, 0);
     if ( badval_ndarray == NULL ) {
        Py_DECREF(data_ndarray);
