pik-copan / pyunicorn

Unified Complex Network and Recurrence Analysis Toolbox
http://pik-potsdam.de/~donges/pyunicorn/
Other
195 stars 87 forks source link

'pip install pyunicorn' no longer works - fails to build wheel #225

Open keriheuer opened 3 months ago

keriheuer commented 3 months ago

My anaconda distribution got corrupted so I had to uninstall and reinstall it to start fresh, which meant having to reinstall all my Python packages. However, I can no longer install pyunicorn via pip or from the source code. I can't tell whether the issue is coming from pip, the version of conda I have now (versus what I had installed back in September) or from updates to the latest version of pyunicorn. I've tried both conda and miniconda from the Anaconda site directly and also via Homebrew (as a cask) -- all methods fail with the latest version of pyunicorn. I was able to do pip install pyunicorn==0.6.0 but then my import statement from pyunicorn.timeseries import RecurrencePlot fails. I've been going nuts all week about this and am very confused as to what happened. I previously installed pyunicorn on this same laptop (MacBook M3) and had installed the package both via pip through Homebrew's anaconda and from the Github repo, on my old laptop (MacBook M1).

Below is the error message I get for any method I've tried. It seems to be coming up when compiling _core.numerics. I'm not very familiar with C but it looks like the numerics.c file has a defined macro 'I' which is overwriting / interfering with the system's default 'I' macro? I even tried adding a monkey patch to a clone of the GitHub repo (also shared below) and then doing pip install . but the same error still came up. Also thought maybe the issue stemmed from my C compiler so I tried both the default version of clang as well as the clang compiler from Homebrew's llvm package. No luck -- both still give me this error. There's also lots of errors or warnings related to Numpy dependencies and header files.

Finally, I don't know if it's related / helpful at all but I notice on my old laptop that the distribution info was stored in an egg.info file instead of the now-used pyproject.toml. I think the last time I installed pyunicorn on this laptop was when it still had egg.info metadata instead of pyproject.toml.

Here is the complete error message:

[keriheuer@Keris-MacBook-Pro-2 ~ % pip install pyunicorn 
Collecting pyunicorn
  Using cached pyunicorn-0.7.0.tar.gz (2.5 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: numpy>=1.24 in /opt/homebrew/anaconda3/lib/python3.11/site-packages (from pyunicorn) (1.26.4)
Requirement already satisfied: scipy>=1.10 in /opt/homebrew/anaconda3/lib/python3.11/site-packages (from pyunicorn) (1.11.4)
Collecting igraph>=0.11 (from pyunicorn)
  Using cached igraph-0.11.5-cp39-abi3-macosx_11_0_arm64.whl.metadata (3.9 kB)
Collecting tqdm>=4.66 (from pyunicorn)
  Using cached tqdm-4.66.4-py3-none-any.whl.metadata (57 kB)
Collecting h5netcdf>=1.1 (from pyunicorn)
  Using cached h5netcdf-1.3.0-py3-none-any.whl.metadata (13 kB)
Requirement already satisfied: h5py in /opt/homebrew/anaconda3/lib/python3.11/site-packages (from h5netcdf>=1.1->pyunicorn) (3.9.0)
Requirement already satisfied: packaging in /opt/homebrew/anaconda3/lib/python3.11/site-packages (from h5netcdf>=1.1->pyunicorn) (23.1)
Collecting texttable>=1.6.2 (from igraph>=0.11->pyunicorn)
  Using cached texttable-1.7.0-py2.py3-none-any.whl.metadata (9.8 kB)
Using cached h5netcdf-1.3.0-py3-none-any.whl (43 kB)
Using cached igraph-0.11.5-cp39-abi3-macosx_11_0_arm64.whl (1.7 MB)
Using cached tqdm-4.66.4-py3-none-any.whl (78 kB)
Using cached texttable-1.7.0-py2.py3-none-any.whl (10 kB)
Building wheels for collected packages: pyunicorn
  Building wheel for pyunicorn (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for pyunicorn (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [183 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build/lib.macosx-11.1-arm64-cpython-311
      creating build/lib.macosx-11.1-arm64-cpython-311/pyunicorn
      copying src/pyunicorn/version.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn
      copying src/pyunicorn/__init__.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn
      creating build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/core
      copying src/pyunicorn/core/interacting_networks.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/core
      copying src/pyunicorn/core/grid.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/core
      copying src/pyunicorn/core/geo_grid.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/core
      copying src/pyunicorn/core/geo_network.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/core
      copying src/pyunicorn/core/resistive_network.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/core
      copying src/pyunicorn/core/cache.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/core
      copying src/pyunicorn/core/__init__.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/core
      copying src/pyunicorn/core/spatial_network.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/core
      copying src/pyunicorn/core/netcdf_dictionary.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/core
      copying src/pyunicorn/core/network.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/core
      copying src/pyunicorn/core/data.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/core
      creating build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/timeseries
      copying src/pyunicorn/timeseries/joint_recurrence_network.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/timeseries
      copying src/pyunicorn/timeseries/recurrence_network.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/timeseries
      copying src/pyunicorn/timeseries/cross_recurrence_plot.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/timeseries
      copying src/pyunicorn/timeseries/joint_recurrence_plot.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/timeseries
      copying src/pyunicorn/timeseries/__init__.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/timeseries
      copying src/pyunicorn/timeseries/visibility_graph.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/timeseries
      copying src/pyunicorn/timeseries/inter_system_recurrence_network.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/timeseries
      copying src/pyunicorn/timeseries/surrogates.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/timeseries
      copying src/pyunicorn/timeseries/recurrence_plot.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/timeseries
      creating build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/eventseries
      copying src/pyunicorn/eventseries/__init__.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/eventseries
      copying src/pyunicorn/eventseries/event_series.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/eventseries
      creating build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/utils
      copying src/pyunicorn/utils/__init__.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/utils
      copying src/pyunicorn/utils/navigator.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/utils
      copying src/pyunicorn/utils/mpi.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/utils
      creating build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/funcnet
      copying src/pyunicorn/funcnet/coupling_analysis_pure_python.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/funcnet
      copying src/pyunicorn/funcnet/__init__.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/funcnet
      copying src/pyunicorn/funcnet/coupling_analysis.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/funcnet
      creating build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/climate
      copying src/pyunicorn/climate/eventseries_climatenetwork.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/climate
      copying src/pyunicorn/climate/spearman.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/climate
      copying src/pyunicorn/climate/rainfall.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/climate
      copying src/pyunicorn/climate/__init__.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/climate
      copying src/pyunicorn/climate/hilbert.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/climate
      copying src/pyunicorn/climate/climate_data.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/climate
      copying src/pyunicorn/climate/tsonis.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/climate
      copying src/pyunicorn/climate/mutual_info.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/climate
      copying src/pyunicorn/climate/coupled_climate_network.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/climate
      copying src/pyunicorn/climate/havlin.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/climate
      copying src/pyunicorn/climate/climate_network.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/climate
      copying src/pyunicorn/climate/map_plot.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/climate
      copying src/pyunicorn/climate/partial_correlation.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/climate
      copying src/pyunicorn/climate/coupled_tsonis.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/climate
      creating build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/core/_ext
      copying src/pyunicorn/core/_ext/__init__.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/core/_ext
      copying src/pyunicorn/core/_ext/types.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/core/_ext
      creating build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/timeseries/_ext
      copying src/pyunicorn/timeseries/_ext/__init__.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/timeseries/_ext
      creating build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/funcnet/_ext
      copying src/pyunicorn/funcnet/_ext/__init__.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/funcnet/_ext
      creating build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/climate/_ext
      copying src/pyunicorn/climate/_ext/__init__.py -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/climate/_ext
      running egg_info
      writing src/pyunicorn.egg-info/PKG-INFO
      writing dependency_links to src/pyunicorn.egg-info/dependency_links.txt
      writing requirements to src/pyunicorn.egg-info/requires.txt
      writing top-level names to src/pyunicorn.egg-info/top_level.txt
      dependency /private/var/folders/1t/cw_9qncx42l90j4kknls85g80000gn/T/pip-build-env-alwrdx3j/overlay/lib/python3.11/site-packages/numpy/_core/include/numpy/arrayobject.h won't be automatically included in the manifest: the path must be relative
      dependency /private/var/folders/1t/cw_9qncx42l90j4kknls85g80000gn/T/pip-build-env-alwrdx3j/overlay/lib/python3.11/site-packages/numpy/_core/include/numpy/arrayscalars.h won't be automatically included in the manifest: the path must be relative
      dependency /private/var/folders/1t/cw_9qncx42l90j4kknls85g80000gn/T/pip-build-env-alwrdx3j/overlay/lib/python3.11/site-packages/numpy/_core/include/numpy/ndarrayobject.h won't be automatically included in the manifest: the path must be relative
      dependency /private/var/folders/1t/cw_9qncx42l90j4kknls85g80000gn/T/pip-build-env-alwrdx3j/overlay/lib/python3.11/site-packages/numpy/_core/include/numpy/ndarraytypes.h won't be automatically included in the manifest: the path must be relative
      dependency /private/var/folders/1t/cw_9qncx42l90j4kknls85g80000gn/T/pip-build-env-alwrdx3j/overlay/lib/python3.11/site-packages/numpy/_core/include/numpy/ufuncobject.h won't be automatically included in the manifest: the path must be relative
      dependency /private/var/folders/1t/cw_9qncx42l90j4kknls85g80000gn/T/pip-build-env-alwrdx3j/overlay/lib/python3.11/site-packages/numpy/_core/include/numpy/arrayobject.h won't be automatically included in the manifest: the path must be relative
      dependency /private/var/folders/1t/cw_9qncx42l90j4kknls85g80000gn/T/pip-build-env-alwrdx3j/overlay/lib/python3.11/site-packages/numpy/_core/include/numpy/arrayscalars.h won't be automatically included in the manifest: the path must be relative
      dependency /private/var/folders/1t/cw_9qncx42l90j4kknls85g80000gn/T/pip-build-env-alwrdx3j/overlay/lib/python3.11/site-packages/numpy/_core/include/numpy/ndarrayobject.h won't be automatically included in the manifest: the path must be relative
      dependency /private/var/folders/1t/cw_9qncx42l90j4kknls85g80000gn/T/pip-build-env-alwrdx3j/overlay/lib/python3.11/site-packages/numpy/_core/include/numpy/ndarraytypes.h won't be automatically included in the manifest: the path must be relative
      dependency /private/var/folders/1t/cw_9qncx42l90j4kknls85g80000gn/T/pip-build-env-alwrdx3j/overlay/lib/python3.11/site-packages/numpy/_core/include/numpy/ufuncobject.h won't be automatically included in the manifest: the path must be relative
      dependency /private/var/folders/1t/cw_9qncx42l90j4kknls85g80000gn/T/pip-build-env-alwrdx3j/overlay/lib/python3.11/site-packages/numpy/_core/include/numpy/arrayobject.h won't be automatically included in the manifest: the path must be relative
      dependency /private/var/folders/1t/cw_9qncx42l90j4kknls85g80000gn/T/pip-build-env-alwrdx3j/overlay/lib/python3.11/site-packages/numpy/_core/include/numpy/arrayscalars.h won't be automatically included in the manifest: the path must be relative
      dependency /private/var/folders/1t/cw_9qncx42l90j4kknls85g80000gn/T/pip-build-env-alwrdx3j/overlay/lib/python3.11/site-packages/numpy/_core/include/numpy/ndarrayobject.h won't be automatically included in the manifest: the path must be relative
      dependency /private/var/folders/1t/cw_9qncx42l90j4kknls85g80000gn/T/pip-build-env-alwrdx3j/overlay/lib/python3.11/site-packages/numpy/_core/include/numpy/ndarraytypes.h won't be automatically included in the manifest: the path must be relative
      dependency /private/var/folders/1t/cw_9qncx42l90j4kknls85g80000gn/T/pip-build-env-alwrdx3j/overlay/lib/python3.11/site-packages/numpy/_core/include/numpy/ufuncobject.h won't be automatically included in the manifest: the path must be relative
      dependency /private/var/folders/1t/cw_9qncx42l90j4kknls85g80000gn/T/pip-build-env-alwrdx3j/overlay/lib/python3.11/site-packages/numpy/_core/include/numpy/arrayobject.h won't be automatically included in the manifest: the path must be relative
      dependency /private/var/folders/1t/cw_9qncx42l90j4kknls85g80000gn/T/pip-build-env-alwrdx3j/overlay/lib/python3.11/site-packages/numpy/_core/include/numpy/arrayscalars.h won't be automatically included in the manifest: the path must be relative
      dependency /private/var/folders/1t/cw_9qncx42l90j4kknls85g80000gn/T/pip-build-env-alwrdx3j/overlay/lib/python3.11/site-packages/numpy/_core/include/numpy/ndarrayobject.h won't be automatically included in the manifest: the path must be relative
      dependency /private/var/folders/1t/cw_9qncx42l90j4kknls85g80000gn/T/pip-build-env-alwrdx3j/overlay/lib/python3.11/site-packages/numpy/_core/include/numpy/ndarraytypes.h won't be automatically included in the manifest: the path must be relative
      dependency /private/var/folders/1t/cw_9qncx42l90j4kknls85g80000gn/T/pip-build-env-alwrdx3j/overlay/lib/python3.11/site-packages/numpy/_core/include/numpy/ufuncobject.h won't be automatically included in the manifest: the path must be relative
      reading manifest file 'src/pyunicorn.egg-info/SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      no previously-included directories found matching 'docs/source/tutorials/images'
      no previously-included directories found matching '**/.ipynb_checkpoints'
      adding license file 'LICENSE.txt'
      writing manifest file 'src/pyunicorn.egg-info/SOURCES.txt'
      copying src/pyunicorn/core/_ext/numerics.pyx -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/core/_ext
      copying src/pyunicorn/core/_ext/src_numerics.c -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/core/_ext
      copying src/pyunicorn/core/_ext/types.pxd -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/core/_ext
      copying src/pyunicorn/timeseries/_ext/numerics.pyx -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/timeseries/_ext
      copying src/pyunicorn/timeseries/_ext/src_numerics.c -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/timeseries/_ext
      copying src/pyunicorn/funcnet/_ext/numerics.pyx -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/funcnet/_ext
      copying src/pyunicorn/climate/_ext/numerics.pyx -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/climate/_ext
      copying src/pyunicorn/climate/_ext/src_numerics.c -> build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/climate/_ext
      running build_ext
      building 'pyunicorn.climate._ext.numerics' extension
      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/pyunicorn
      creating build/temp.macosx-11.1-arm64-cpython-311/src/pyunicorn/climate
      creating build/temp.macosx-11.1-arm64-cpython-311/src/pyunicorn/climate/_ext
      clang -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /opt/homebrew/anaconda3/include -arch arm64 -fPIC -O2 -isystem /opt/homebrew/anaconda3/include -arch arm64 -I/opt/homebrew/opt/openjdk/include -D_GNU_SOURCE -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -Isrc/pyunicorn/climate/_ext -I/private/var/folders/1t/cw_9qncx42l90j4kknls85g80000gn/T/pip-build-env-alwrdx3j/overlay/lib/python3.11/site-packages/numpy/_core/include -I/opt/homebrew/anaconda3/include/python3.11 -c src/pyunicorn/climate/_ext/numerics.c -o build/temp.macosx-11.1-arm64-cpython-311/src/pyunicorn/climate/_ext/numerics.o -O3 -std=c99 -Wall
      clang -bundle -undefined dynamic_lookup -Wl,-rpath,/opt/homebrew/anaconda3/lib -L/opt/homebrew/anaconda3/lib -Wl,-rpath,/opt/homebrew/anaconda3/lib -L/opt/homebrew/anaconda3/lib -I/opt/homebrew/opt/openjdk/include build/temp.macosx-11.1-arm64-cpython-311/src/pyunicorn/climate/_ext/numerics.o -o build/lib.macosx-11.1-arm64-cpython-311/pyunicorn/climate/_ext/numerics.cpython-311-darwin.so
      ld: warning: duplicate -rpath '/opt/homebrew/anaconda3/lib' ignored
      building 'pyunicorn.core._ext.numerics' extension
      creating build/temp.macosx-11.1-arm64-cpython-311/src/pyunicorn/core
      creating build/temp.macosx-11.1-arm64-cpython-311/src/pyunicorn/core/_ext
      clang -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /opt/homebrew/anaconda3/include -arch arm64 -fPIC -O2 -isystem /opt/homebrew/anaconda3/include -arch arm64 -I/opt/homebrew/opt/openjdk/include -D_GNU_SOURCE -DNPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION -Isrc/pyunicorn/core/_ext -I/private/var/folders/1t/cw_9qncx42l90j4kknls85g80000gn/T/pip-build-env-alwrdx3j/overlay/lib/python3.11/site-packages/numpy/_core/include -I/opt/homebrew/anaconda3/include/python3.11 -c src/pyunicorn/core/_ext/numerics.c -o build/temp.macosx-11.1-arm64-cpython-311/src/pyunicorn/core/_ext/numerics.o -O3 -std=c99 -Wall
      In file included from src/pyunicorn/core/_ext/numerics.c:1271:
      src/pyunicorn/core/_ext/src_numerics.c:121:12: error: expected identifier or '('
          double I=0;
                 ^
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/complex.h:42:11: note: expanded from macro 'I'
      #define I _Complex_I
                ^
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/complex.h:40:21: note: expanded from macro '_Complex_I'
      #define _Complex_I (__extension__ 1.0iF)
                          ^
      In file included from src/pyunicorn/core/_ext/numerics.c:1271:
      src/pyunicorn/core/_ext/src_numerics.c:121:12: error: expected ')'
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/complex.h:42:11: note: expanded from macro 'I'
      #define I _Complex_I
                ^
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/complex.h:40:21: note: expanded from macro '_Complex_I'
      #define _Complex_I (__extension__ 1.0iF)
                          ^
      src/pyunicorn/core/_ext/src_numerics.c:121:12: note: to match this '('
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/complex.h:42:11: note: expanded from macro 'I'
      #define I _Complex_I
                ^
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/complex.h:40:20: note: expanded from macro '_Complex_I'
      #define _Complex_I (__extension__ 1.0iF)
                         ^
      In file included from src/pyunicorn/core/_ext/numerics.c:1271:
      src/pyunicorn/core/_ext/src_numerics.c:125:15: error: expression is not assignable
                  I = 0.0;
                  ~ ^
      src/pyunicorn/core/_ext/src_numerics.c:131:23: error: expression is not assignable
                          I += admittance[i*N+j]*
                          ~ ^
      src/pyunicorn/core/_ext/src_numerics.c:152:12: error: expected identifier or '('
          double I = 0.0;
                 ^
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/complex.h:42:11: note: expanded from macro 'I'
      #define I _Complex_I
                ^
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/complex.h:40:21: note: expanded from macro '_Complex_I'
      #define _Complex_I (__extension__ 1.0iF)
                          ^
      In file included from src/pyunicorn/core/_ext/numerics.c:1271:
      src/pyunicorn/core/_ext/src_numerics.c:152:12: error: expected ')'
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/complex.h:42:11: note: expanded from macro 'I'
      #define I _Complex_I
                ^
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/complex.h:40:21: note: expanded from macro '_Complex_I'
      #define _Complex_I (__extension__ 1.0iF)
                          ^
      src/pyunicorn/core/_ext/src_numerics.c:152:12: note: to match this '('
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/complex.h:42:11: note: expanded from macro 'I'
      #define I _Complex_I
                ^
      /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/complex.h:40:20: note: expanded from macro '_Complex_I'
      #define _Complex_I (__extension__ 1.0iF)
                         ^
      In file included from src/pyunicorn/core/_ext/numerics.c:1271:
      src/pyunicorn/core/_ext/src_numerics.c:156:15: error: expression is not assignable
                  I = 0.0;
                  ~ ^
      src/pyunicorn/core/_ext/src_numerics.c:159:23: error: expression is not assignable
                          I += admittance[i*N+j]*\
                          ~ ^
      8 errors 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 pyunicorn
Failed to build pyunicorn
ERROR: Could not build wheels for pyunicorn, which is required to install pyproject.toml-based projects](url)

The monkey patch I tried to add:

--- a/src/pyunicorn/core/_ext/src_numerics.c
+++ b/src/pyunicorn/core/_ext/src_numerics.c
@@ -121,7 +121,7 @@
     double conductance=0, susceptance=0;
     double conductance_pq, susceptance_pq;
     int j;
-    double I=0;
+    double current=0;

     if (!( conductance_pq = admittance[i*N+j] ))
         continue;

System info: OS: Macbook M3 Max Python version: Multiple (3.10, 3.11.7, 3.12.3, 3.14.3, 3.14.4) conda version: Multiple (24.1.2, 24.4.0) miniconda version: Multiple (24.1.2, 24.4.0) pyunicorn versions: Multiple (0.6.0, 0.7.0, 0.7.0.a1 from a fork in my repositories of a previous version that has since been removed from your Github)

fkuehlein commented 3 months ago

Hi @keriheuer,

thank you for reporting this!

I run into the exact same problem when installing pyunicorn, no matter what version. The install worked until recently so I suspect the problem comes from updates in the dependencies, most probably with the C compiler or Cython itself.

In fact, as you noticed, the problem appears simply to be with the variable name I used inside the core/_ext/src_numerics.c file. It interferes with C's own macro I which is used for the imaginary unit when the complex library is included (#include <complex.h>). Although the complex library is not included in core/_ext/src_numerics.c, Cython might automatically include it. Not sure how this did not cause any problems previously, might be an update to Cython or the used C compiler. I couldn't find out about a way to direct Cython not to include the complex library. One could explicitly include the library inside the file and undefine the macro (#include <complex.h>; #undef I), but as we don't want to use complex numbers in the first place, I think simply renaming the variable is the smoother option. I will open a branch to implement that.

It would still be cool to find out what dependency actually caused this problem to pop up. This way you might still be able to use pyunicorn v0.7.0 from pip making sure to use a previous version of the respective dependency. Unfortunately couldn't figure that out yet, using older versions of Cython and setuptools didn't fix it. Any ideas are most welcome! :)

fkuehlein commented 3 months ago

Just merged it, hope this solves your issue when installing the most recent development version via pip install git+https://github.com/pik-copan/pyunicorn.git. Let me know otherwise!

Will leave the issue open for the pip install of v0.7.0 which is not yet resolved.

steyev commented 2 months ago

This most recent development version also solved an error message I had while running cell 4 or 5 from the tutorial on climate networks. I can't reproduce it so can't be more specific, sorry. But it might be of help for you finding out which dependency caused this. numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

fkuehlein commented 2 months ago

Thanks for reporting. Do you remember if you were using numpy>=2.0 when that error occurred? Then it might also be related to #228. In the meantime, I could already rule out numpy as the cause of this issue though.

steyev commented 2 months ago

I believe I used numpy 1.26.4

fkuehlein commented 2 months ago

Little update on the last comment: It seems like these types of errors are actually produced when using Numpy 2.0 with yet incompatible versions of other dependencies, similar to this thread. In the specific case of the ClimateNetworks tutorial I could reproduce this behavior when calling pyunicorn.core.Data (via pyunicorn.climate.ClimateData) using numpy==2.0.0 with h5py<=3.10. Therefore I am confident it should actually not be related to this issue but to #228. See that issue for further reference.