cylammarco / SpectResC

SpectResC is an implementation of SpectRes with C-extension in Python.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cannot build on MacOS

StuartLittlefair opened this issue · comments

When installing via pip or from most recent source build there are warnings and errors about incompatible pointer types, with the last one causing an error:

running build
running build_ext
building 'spectresc' extension
creating build
creating build/temp.macosx-11.1-arm64-cpython-311
creating build/temp.macosx-11.1-arm64-cpython-311/src
creating build/temp.macosx-11.1-arm64-cpython-311/src/spectresc
clang -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /Users/sl/anaconda3/envs/py311/include -arch arm64 -fPIC -O2 -isystem /Users/sl/anaconda3/envs/py311/include -arch arm64 -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -I/opt/homebrew/include -I/opt/trm_code/include -I/opt/extra/include -I/opt/X11/include -I/usr/local/lib -I/Users/sl/anaconda3/envs/py311/lib/python3.11/site-packages/numpy/core/include -I/Users/sl/anaconda3/envs/py311/include/python3.11 -c src/spectresc/spectres.c -o build/temp.macosx-11.1-arm64-cpython-311/src/spectresc/spectres.o -O3 -fPIC -shared
clang: warning: argument unused during compilation: '-shared' [-Wunused-command-line-argument]
In file included from src/spectresc/spectres.c:5:
In file included from /Users/sl/anaconda3/envs/py311/lib/python3.11/site-packages/numpy/core/include/numpy/arrayobject.h:5:
In file included from /Users/sl/anaconda3/envs/py311/lib/python3.11/site-packages/numpy/core/include/numpy/ndarrayobject.h:12:
In file included from /Users/sl/anaconda3/envs/py311/lib/python3.11/site-packages/numpy/core/include/numpy/ndarraytypes.h:1940:
/Users/sl/anaconda3/envs/py311/lib/python3.11/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: "Using deprecated NumPy API, disable it with "          "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-W#warnings]
#warning "Using deprecated NumPy API, disable it with " \
 ^
src/spectresc/spectres.c:281:51: warning: incompatible pointer types passing 'PyObject *' (aka 'struct _object *') to parameter of type 'PyArrayObject *' (aka 'struct tagPyArrayObject_fields *') [-Wincompatible-pointer-types]
        PyList_Append(result_list, PyArray_Return(new_fluxes_array));
                                                  ^~~~~~~~~~~~~~~~
src/spectresc/spectres.c:284:51: warning: incompatible pointer types passing 'PyObject *' (aka 'struct _object *') to parameter of type 'PyArrayObject *' (aka 'struct tagPyArrayObject_fields *') [-Wincompatible-pointer-types]
        PyList_Append(result_list, PyArray_Return(new_errs_array));
                                                  ^~~~~~~~~~~~~~
src/spectresc/spectres.c:150:15: warning: unused variable 'spec_errs_array' [-Wunused-variable]
    PyObject *spec_errs_array = NULL;
              ^
src/spectresc/spectres.c:295:18: error: incompatible function pointer types initializing 'PyCFunction' (aka 'struct _object *(*)(struct _object *, struct _object *)') with an expression of type 'PyObject *(PyObject *, PyObject *, PyObject *)' (aka 'struct _object *(struct _object *, struct _object *, struct _object *)') [-Wincompatible-function-pointer-types]
    {"spectres", spectres, METH_VARARGS | METH_KEYWORDS, "Resample a spectrum onto a new wavelength grid."},
                 ^~~~~~~~
4 warnings and 1 error generated.
error: command '/usr/bin/clang' failed with exit code 1

Sorry @StuartLittlefair, only just noticed the issue. I'll look into it, hopefully, it's a simple numpy API change...

Hi @StuartLittlefair, would you please try the develop branch and see if it works? I tested it locally and it seems fine now.

Published as v1.0.4. I hope it works, I'm keeping this open in case...