Files
ports/math/py-numpy1/files/patch-swig44
T
Charlie Li 634b014274 math/py-numpy1: restore mistakenly removed patch
Leads to breakages like math/py-nlopt:

[ 98%] Building CXX object extern/nlopt/src/swig/CMakeFiles/nlopt_python.dir/CMakeFiles/nlopt_python.dir/nloptPYTHON_wrap.cxx.o
/wrkdirs/usr/ports/math/py-nlopt/work-py311/nlopt-python-2.9.1/build/temp.freebsd-14.3-RELEASE-p10-i386-cpython-311/extern/nlopt/src/swig/CMakeFiles/nlopt_python.dir/nloptPYTHON_wrap.cxx:15325:3: error: cannot initialize return object of type 'int' with an rvalue of type 'std::nullptr_t'
 15325 |   import_array();
       |   ^~~~~~~~~~~~~~
/usr/local/lib/python3.11/site-packages/numpy/core/include/numpy/__multiarray_api.h:1558:151: note: expanded from macro 'import_array'
 1558 | #define import_array() {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return NULL; } }
      |                                                                                                                                                       ^~~~
/usr/include/sys/_null.h:35:14: note: expanded from macro 'NULL'
   35 | #define NULL    nullptr
      |                 ^~~~~~~
1 error generated.

Reported by: diizzy, fallout
2026-04-05 10:51:30 -04:00

20 lines
885 B
Plaintext

Reference: https://github.com/numpy/numpy/commit/1e424dae42a2d560520b6e053e8e60ac4205bfc7
--- numpy/core/code_generators/generate_numpy_api.py.orig 2024-02-05 21:17:48 UTC
+++ numpy/core/code_generators/generate_numpy_api.py
@@ -118,7 +118,13 @@ _import_array(void)
return 0;
}
-#define import_array() {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return NULL; } }
+#if (SWIG_VERSION < 0x040400)
+#define _RETURN_VALUE NULL
+#else
+#define _RETURN_VALUE 0
+#endif
+
+#define import_array() {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return _RETURN_VALUE; } }
#define import_array1(ret) {if (_import_array() < 0) {PyErr_Print(); PyErr_SetString(PyExc_ImportError, "numpy.core.multiarray failed to import"); return ret; } }