SopiMlab/py

PY_NUMPY_BUFFER_FORMAT declared conditionally but used unconditionally

Opened this issue · 2 comments

in pybuffer.cpp, the PY_NUMPY_BUFFER_FORMAT is defined only if PY_NUMPY is already defined:

py/source/pybuffer.cpp

Lines 31 to 37 in 35138a0

# if defined(PY_NUMPY)
# include <numpy/arrayobject.h>
# if _FLEXT_NEED_SAMPLE_CONV
# define PY_NUMPY_BUFFER_FORMAT "f"
# else
# define PY_NUMPY_BUFFER_FORMAT "d"
# endif

but later on, it is used even if PY_NUMPY is not defined:

view->format = (flags & PyBUF_FORMAT) ? (char *) PY_NUMPY_BUFFER_FORMAT : NULL;

this obviously break the build if PY_NUMPY is not defined...

I manage to build replacing the line
view->format = (flags & PyBUF_FORMAT) ? (char *) PY_NUMPY_BUFFER_FORMAT : NULL;
with

view->format = (flags & PyBUF_FORMAT) ? ((Py_buffer*)view)->format : NULL;

But I'm getting linking errors on loading the py.pd_linux external in puredata... (says symbol PyExc_ValueError is undefined even tho I make sure to link -lpython3 at build time...)

But I'm getting linking errors on loading the py.pd_linux external in puredata... (says symbol PyExc_ValueError is undefined even tho I make sure to link -lpython3 at build time...)

Had to set rpath for better linking. Made a pull request for linking reinforcement and newer numpy versions support