lballabio / QuantLib-SWIG

QuantLib wrappers to other languages
Other
338 stars 282 forks source link

Cannot build SWIG for python 3.9 #631

Closed kohnech closed 5 months ago

kohnech commented 5 months ago

Since PR #629 We are not able to compile SWIG for python 3.9. Example build errors:

QuantLib/quantlib_wrap.cpp: In function ‘char* SWIG_Python_str_AsChar(PyObject*)’:
QuantLib/quantlib_wrap.cpp:812:18: error: ‘PyUnicode_AsUTF8’ was not declared in this scope; did you mean ‘PyUnicode_AsUCS4’?
  812 |   return (char *)PyUnicode_AsUTF8(str);
      |                  ^~~~~~~~~~~~~~~~
      |                  PyUnicode_AsUCS4
QuantLib/quantlib_wrap.cpp: In function ‘Py_ssize_t SWIG_Python_UnpackTuple(PyObject*, const char*, Py_ssize_t, Py_ssize_t, PyObject**)’:
QuantLib/quantlib_wrap.cpp:1228:20: error: ‘PyTuple_GET_SIZE’ was not declared in this scope; did you mean ‘Py_SET_SIZE’?
 1228 |     Py_ssize_t l = PyTuple_GET_SIZE(args);
      |                    ^~~~~~~~~~~~~~~~
      |                    Py_SET_SIZE
QuantLib/quantlib_wrap.cpp:1240:12: error: ‘PyTuple_GET_ITEM’ was not declared in this scope
 1240 |  objs[i] = PyTuple_GET_ITEM(args, i);

We build with standard configuration similar to https://github.com/lballabio/QuantLib-SWIG/blob/master/.ci/python.build We have the same issue for both Linux and Windows.

boring-cyborg[bot] commented 5 months ago

Thanks for posting! It might take a while before we look at your issue, so don't worry if there seems to be no feedback. We'll get to it.

lballabio commented 5 months ago

Hello—you'll need to upgrade to SWIG 4.2, previous versions didn't support the limited API.

kohnech commented 5 months ago

Thank you!