tobiscode / disstans

Package repository for the Decomposition and Inference of Sources through Spatiotemporal Analysis of Network Signals (DISSTANS) toolbox.
https://tobiscode.github.io/disstans/
GNU General Public License v3.0
22 stars 7 forks source link

Installation issue: compiler problems #2

Closed tobiscode closed 1 year ago

tobiscode commented 1 year ago

I've noticed that sometimes users installing DISSTANS (or okada_wrapper) run into the following compilation errors:

Collecting disstans
  Using cached disstans-1.1.1.tar.gz (161 kB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
  Preparing metadata (pyproject.toml) ... done
Building wheels for collected packages: disstans
  Building wheel for disstans (pyproject.toml) ... error
  error: subprocess-exited-with-error

  × Building wheel for disstans (pyproject.toml) did not run successfully.
  │ exit code: 1
  ╰─> [393 lines of output]

   ...

   build/src.linux-x86_64-3.10/build/src.linux-x86_64-3.10/disstans/fortranobject.c:729:5: note: use option -std=c99 or -std=gnu99 to compile your code
      error: Command "gcc -pthread -B <someinstallfolder>/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem <someinstallfolder>/include -fPIC -O2 -isystem <someinstallfolder>/include -fPIC -Ibuild/src.linux-x86_64-3.10/build/src.linux-x86_64-3.10/disstans -I/tmp/pip-build-env-y4g17j4o/overlay/lib/python3.10/site-packages/numpy/core/include -Ibuild/src.linux-x86_64-3.10/numpy/distutils/include -I<someinstallfolder>/include/python3.10 -c build/src.linux-x86_64-3.10/build/src.linux-x86_64-3.10/disstans/fortranobject.c -o build/temp.linux-x86_64-cpython-310/build/src.linux-x86_64-3.10/build/src.linux-x86_64-3.10/disstans/fortranobject.o -MMD -MF build/temp.linux-x86_64-cpython-310/build/src.linux-x86_64-3.10/build/src.linux-x86_64-3.10/disstans/fortranobject.o.d -msse -msse2 -msse3" failed with exit status 1
      INFO:
      ########### EXT COMPILER OPTIMIZATION ###########
      INFO: Platform      :
        Architecture: x64
        Compiler    : gcc

      CPU baseline  :
        Requested   : 'min'
        Enabled     : SSE SSE2 SSE3
        Flags       : -msse -msse2 -msse3
        Extra checks: none

      CPU dispatch  :
        Requested   : 'max -xop -fma4'
        Enabled     : SSSE3 SSE41 POPCNT SSE42 AVX F16C FMA3 AVX2
        Generated   : none
      INFO: CCompilerOpt.cache_flush[857] : write cache to path -> /tmp/pip-install-7a2gn00j/disstans_2adeca4296e74af7b1c9ce8ffb5c9d28/build/temp.linux-x86_64-cpython-310/ccompiler_opt_cache_ext.py
      [end of output]

  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for disstans
Failed to build disstans
ERROR: Could not build wheels for disstans, which is required to install pyproject.toml-based projects
tobiscode commented 1 year ago

This is due to old GCC compilers not using C99 syntax by default. To prevent this problem, you can either update the GCC compilers to a more modern version, or force the old GCC compiler to use the more modern standard by prepending the CFLAGS environment variable when running pip:

> CFLAGS="-std=c99" pip install disstans

This should fix the issue. The same workaround can be applied to editable installations or installations from the git repository.