I'm puzzled by the following issue. I have a Mac M3 with the following characteristics.
I have Python 3.12.6. I have been trying to install pyo (https://pypi.org/project/pyo/1.0.1/). After many issues with the location of the headers, I could solve all the "I do not find blablaheader.h" with the following command:
pip3 install --global-option='build_ext' --global-option='-I/opt/homebrew/Cellar/portaudio/19.7.0/include’ --global-option='-L/opt/homebrew/Cellar/portaudio/19.7.0/lib’ pyo==1.0.1
But now I have the following error and it is very puzzling. It looks like a C error syntax on an extension?
clang -fno-strict-overflow -Wsign-compare -Wunreachable-code -fno-common -dynamic -DNDEBUG -g -O3 -Wall -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk -I/opt/homebrew/include/ -I/opt/homebrew/Cellar/unixodbc/2.3.12/include -DUSE_PORTAUDIO -DUSE_PORTMIDI -DUSE_OSC -Iinclude -I/usr/include -I/usr/local/include -I/opt/local/include -I/Users/alejandro/projects/generate-music/venv/include -I/opt/homebrew/opt/python@3.12/Frameworks/Python.framework/Versions/3.12/include/python3.12 -c src/objects/bandsplitmodule.c -o build/temp.macosx-14.0-arm64-cpython-312/src/objects/bandsplitmodule.o -Wno-strict-prototypes -Wno-strict-aliasing -O3 -g0 -DNDEBUG
src/objects/bandsplitmodule.c:1639:8: error: expected '(' after 'if'
if PyList_Check(arg) {
^
/opt/homebrew/opt/python@3.12/Frameworks/Python.framework/Versions/3.12/include/python3.12/listobject.h:25:5: note: expanded from macro 'PyList_Check'
PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_LIST_SUBCLASS)
^
/opt/homebrew/opt/python@3.12/Frameworks/Python.framework/Versions/3.12/include/python3.12/object.h:971:41: note: expanded from macro 'PyType_FastSubclass'
#define PyType_FastSubclass(type, flag) PyType_HasFeature((type), (flag))
^
1 error generated.
error: command '/usr/bin/clang' failed with exit code 1
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for pyo
Failed to build pyo
I really doubt extensions had this kind of error, so it is most probably a C version issue. Maybe it is C++, and my system only has a C compiler? I do not know.
I really need some "directions" here.
The answer is that the extension does have a problem. More specifically, it has a syntax error. The author of pyo
has omitted the parentheses from the condition expression of the if-statement, which is not permitted in C. Presumably, a previous version of libpython
defined the PyList_Check(...)
macro with enclosing parentheses that have been removed since then.
The simplest solution is to install a newer version of pyo
that has corrected the syntax error; 1.0.4 appears to be the oldest version that has corrected the syntax error. 1.0.5 is the most recent version.
If you absolutely must use version 1.0.1, then you should write a patch. The steps to do that are as follows:
pip path/to/directory
(see this answer)