NextGenCMB / delensalot

Curved-sky iterative CMB lensing tools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Installation issue when using gcc > version 7

louisl3grand opened this issue · comments

When trying to install lenscarf with a conda environment in python 3.10 I got this error.
It did not appear when using python 3.9.

>>> pip install -e .
Obtaining file:///global/u2/l/llegrand/lenscarf
  Preparing metadata (setup.py) ... done
Requirement already satisfied: numpy in /global/u2/l/llegrand/.conda/envs/scarf6/lib/python3.10/site-packages (from lenscarf==0.0.1) (1.22.0)
Requirement already satisfied: pyfftw in /global/u2/l/llegrand/.conda/envs/scarf6/lib/python3.10/site-packages (from lenscarf==0.0.1) (0.13.0)
Installing collected packages: lenscarf
  Running setup.py develop for lenscarf
    ERROR: Command errored out with exit status 1:
     command: /global/homes/l/llegrand/.conda/envs/scarf6/bin/python3.1 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/global/u2/l/llegrand/lenscarf/setup.py'"'"'; __file__='"'"'/global/u2/l/llegrand/lenscarf/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps
         cwd: /global/u2/l/llegrand/lenscarf/
    Complete output (53 lines):
    running develop
    /global/homes/l/llegrand/.conda/envs/scarf6/lib/python3.10/site-packages/setuptools/command/easy_install.py:156: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
      warnings.warn(
    /global/homes/l/llegrand/.conda/envs/scarf6/lib/python3.10/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
      warnings.warn(
    running build_scripts
    running egg_info
    running build_src
    /global/homes/l/llegrand/.conda/envs/scarf6/lib/python3.10/site-packages/setuptools/command/egg_info.py:624: SetuptoolsDeprecationWarning: Custom 'build_py' does not implement 'get_data_files_without_manifest'.
    Please extend command classes from setuptools instead of distutils.
      warnings.warn(
    writing manifest file 'lenscarf.egg-info/SOURCES.txt'
    running build_ext
    creating /tmp/tmp4uh9g_m7/global
    creating /tmp/tmp4uh9g_m7/global/u2
    creating /tmp/tmp4uh9g_m7/global/u2/l
    creating /tmp/tmp4uh9g_m7/global/u2/l/llegrand
    creating /tmp/tmp4uh9g_m7/global/u2/l/llegrand/.conda
    creating /tmp/tmp4uh9g_m7/global/u2/l/llegrand/.conda/envs
    creating /tmp/tmp4uh9g_m7/global/u2/l/llegrand/.conda/envs/scarf6
    creating /tmp/tmp4uh9g_m7/global/u2/l/llegrand/.conda/envs/scarf6/lib
    creating /tmp/tmp4uh9g_m7/global/u2/l/llegrand/.conda/envs/scarf6/lib/python3.10
    creating /tmp/tmp4uh9g_m7/global/u2/l/llegrand/.conda/envs/scarf6/lib/python3.10/site-packages
    creating /tmp/tmp4uh9g_m7/global/u2/l/llegrand/.conda/envs/scarf6/lib/python3.10/site-packages/numpy
    creating /tmp/tmp4uh9g_m7/global/u2/l/llegrand/.conda/envs/scarf6/lib/python3.10/site-packages/numpy/distutils
    creating /tmp/tmp4uh9g_m7/global/u2/l/llegrand/.conda/envs/scarf6/lib/python3.10/site-packages/numpy/distutils/checks
    WARN: Could not locate executable armflang
    In file included from /global/homes/l/llegrand/.conda/envs/scarf6/lib/python3.10/site-packages/numpy/core/include/numpy/ndarraytypes.h:1960,
                     from /global/homes/l/llegrand/.conda/envs/scarf6/lib/python3.10/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
                     from /global/homes/l/llegrand/.conda/envs/scarf6/lib/python3.10/site-packages/numpy/core/include/numpy/arrayobject.h:5,
                     from build/src.linux-x86_64-3.10/build/src.linux-x86_64-3.10/lenscarf/fortran/fortranobject.h:13,
                     from build/src.linux-x86_64-3.10/lenscarf/fortran/remappingmodule.c:20:
    /global/homes/l/llegrand/.conda/envs/scarf6/lib/python3.10/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
     #warning "Using deprecated NumPy API, disable it with " \
      ^~~~~~~
    In file included from /global/homes/l/llegrand/.conda/envs/scarf6/lib/python3.10/site-packages/numpy/core/include/numpy/ndarraytypes.h:1960,
                     from /global/homes/l/llegrand/.conda/envs/scarf6/lib/python3.10/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,
                     from /global/homes/l/llegrand/.conda/envs/scarf6/lib/python3.10/site-packages/numpy/core/include/numpy/arrayobject.h:5,
                     from build/src.linux-x86_64-3.10/build/src.linux-x86_64-3.10/lenscarf/fortran/fortranobject.h:13,
                     from build/src.linux-x86_64-3.10/build/src.linux-x86_64-3.10/lenscarf/fortran/fortranobject.c:2:
    /global/homes/l/llegrand/.conda/envs/scarf6/lib/python3.10/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning "Using deprecated NumPy API, disable it with " "#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION" [-Wcpp]
     #warning "Using deprecated NumPy API, disable it with " \
      ^~~~~~~
    build/src.linux-x86_64-3.10/lenscarf/fortran/remappingmodule.c: In function 'f2py_rout_remapping_bicubic_eval':
    build/src.linux-x86_64-3.10/lenscarf/fortran/remappingmodule.c:389:25: error: expected expression before ',' token
         ftl_map_Dims[0]=1 + ,ftl_map_Dims[1]=1 + ;
                             ^
    build/src.linux-x86_64-3.10/lenscarf/fortran/remappingmodule.c:389:25: warning: left-hand operand of comma expression has no effect [-Wunused-value]
    At top level:
    build/src.linux-x86_64-3.10/lenscarf/fortran/remappingmodule.c:113:12: warning: 'f2py_size' defined but not used [-Wunused-function]
     static int f2py_size(PyArrayObject* var, ...)
                ^~~~~~~~~
    error: Command "gcc -pthread -B /global/homes/l/llegrand/.conda/envs/scarf6/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -fPIC -O2 -isystem /global/homes/l/llegrand/.conda/envs/scarf6/include -fPIC -O2 -isystem /global/homes/l/llegrand/.conda/envs/scarf6/include -fPIC -Ibuild/src.linux-x86_64-3.10/build/src.linux-x86_64-3.10/lenscarf/fortran -I/global/homes/l/llegrand/.conda/envs/scarf6/lib/python3.10/site-packages/numpy/core/include -Ibuild/src.linux-x86_64-3.10/numpy/distutils/include -I/global/homes/l/llegrand/.conda/envs/scarf6/include/python3.10 -I/global/homes/l/llegrand/.conda/envs/scarf6/include/python3.10 -c build/src.linux-x86_64-3.10/lenscarf/fortran/remappingmodule.c -o build/temp.linux-x86_64-3.10/build/src.linux-x86_64-3.10/lenscarf/fortran/remappingmodule.o -MMD -MF build/temp.linux-x86_64-3.10/build/src.linux-x86_64-3.10/lenscarf/fortran/remappingmodule.o.d -msse -msse2 -msse3" failed with exit status 1
    ----------------------------------------
ERROR: Command errored out with exit status 1: /global/homes/l/llegrand/.conda/envs/scarf6/bin/python3.1 -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/global/u2/l/llegrand/lenscarf/setup.py'"'"'; __file__='"'"'/global/u2/l/llegrand/lenscarf/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps Check the logs for full command output.

It seems that it is due to the f2py module.
When comparing line 389 of lenscarf/build/src.linux-x86_64-3.10/lenscarf/fortran/remappingmodule.c with line 373 of lenscarf/build/src.linux-x86_64-3.9/lenscarf/fortran/remappingmodule.c I see for the 3.10 version:
ftl_map_Dims[0]=1 + ,ftl_map_Dims[1]=1 + ;
and for the 3.9 version
ftl_map_Dims[0]=1,ftl_map_Dims[1]=1;

I observed the same problem using python 3.9.

It looks to me as though this is a gfortran version issue.
On my personal computer and using gcc version 11.2.1, I get the same error.
Adding extra f90 compile arguments such as -std=legacy, -fallow-argument-mismatch or -freal-4-real-8 did not resolve the issue.

However, I tried installing it in a docker container with gcc 7.0 and the installation worked.

Solved by #30