[meta-python][PATCH 1/4] python3-fann2: add SWIG py2/py3 C-API compat patch

Khem Raj <[email protected]>
Newsgroups org.openembedded.lists.openembedded-devel
Message-ID <[email protected]>
fann2.i's HELPER_ARRAY_TEMPLATE typemaps use the Python 2 C-API names
PyInt_Check/PyInt_AsLong/PyInt_FromLong. Python 3.14 no longer ships
any fallback definitions for them, so the SWIG-generated wrapper
fails to compile:

  fann2/fann2_wrap.cxx:10062:41: error: use of undeclared identifier 'PyInt_AsLong'; did you mean 'PyLong_AsLong'?

Add a patch mapping them to their PyLong_* equivalents.

Signed-off-by: Khem Raj <[email protected]>
---
 ...n2.i-add-py2-py3-C-API-compat-macros.patch | 36 +++++++++++++++++++
 .../python/python3-fann2_1.1.2.bb             |  1 +
 2 files changed, 37 insertions(+)
 create mode 100644 meta-python/recipes-devtools/python/python3-fann2/0002-fann2.i-add-py2-py3-C-API-compat-macros.patch

diff --git a/meta-python/recipes-devtools/python/python3-fann2/0002-fann2.i-add-py2-py3-C-API-compat-macros.patch b/meta-python/recipes-devtools/python/python3-fann2/0002-fann2.i-add-py2-py3-C-API-compat-macros.patch
new file mode 100644
index 0000000000..03f59b38ba
--- /dev/null
+++ b/meta-python/recipes-devtools/python/python3-fann2/0002-fann2.i-add-py2-py3-C-API-compat-macros.patch
@@ -0,0 +1,36 @@
+From: Khem Raj <[email protected]>
+Subject: fann2.i: add py2/py3 C-API compat macros
+
+The HELPER_ARRAY_TEMPLATE typemaps in fann2.i use the Python 2 C-API
+names PyInt_Check/PyInt_AsLong/PyInt_FromLong. Python 3.14 no longer
+ships any fallback definitions for them, so the SWIG-generated wrapper
+fails to compile:
+
+  fann2/fann2_wrap.cxx:10062:41: error: use of undeclared identifier 'PyInt_AsLong'; did you mean 'PyLong_AsLong'?
+
+Map them to their PyLong_* equivalents.
+
+Upstream-Status: Pending
+Signed-off-by: Khem Raj <[email protected]>
+---
+--- a/fann2/fann2.i
++++ b/fann2/fann2.i
+@@ -15,6 +15,18 @@
+ #include "fann_cpp_subclass.h"
+ %}
+
++%{
++#ifndef PyInt_Check
++#define PyInt_Check(x) PyLong_Check(x)
++#endif
++#ifndef PyInt_AsLong
++#define PyInt_AsLong(x) PyLong_AsLong(x)
++#endif
++#ifndef PyInt_FromLong
++#define PyInt_FromLong(x) PyLong_FromLong(x)
++#endif
++%}
++
+ %define HELPER_ARRAY_TEMPLATE( templ , T, GetFunc, SetFunc, cast)
+     %typemap(in) templ<T> *  (templ<T> temp){
+         // templ<T>* type_map in
diff --git a/meta-python/recipes-devtools/python/python3-fann2_1.1.2.bb b/meta-python/recipes-devtools/python/python3-fann2_1.1.2.bb
index 3053ca5d71..c2170f6bb0 100644
--- a/meta-python/recipes-devtools/python/python3-fann2_1.1.2.bb
+++ b/meta-python/recipes-devtools/python/python3-fann2_1.1.2.bb
@@ -6,6 +6,7 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=c73b943dc75f6f65e007c56ac6515c8f"
 SRC_URI[sha256sum] = "cdca0a65ad48e08320672affe38c3dd4ea15e27821e5e1db9fa2b34299bdd41e"

 SRC_URI += " file://0001-setup.py-Don-t-hardcode-swig-and-fann2-binary-locati.patch"
+SRC_URI += " file://0002-fann2.i-add-py2-py3-C-API-compat-macros.patch"

 inherit pypi setuptools3
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.