fastscape-lem / fastscapelib-fortran

A Fortran (+ Python bindings) library of efficient algorithms for landscape evolution modeling
https://fastscape-lem.github.io/fastscapelib-fortran/
GNU General Public License v3.0
23 stars 17 forks source link

Install Python package from source fails on Ubuntu 20.04 #48

Open rbrtmch opened 2 years ago

rbrtmch commented 2 years ago

I get an error building from source on Ubuntu 20.04. Fortran build works without issue, only the python package build fails. I tried the build with --no-build-isolation and got the same error. Attached is a screen dump of the build. The following versions were used. Python 3.8.10 numpy 1.22.2 wheel 0.37.1 setuptools 60.8.1 scikit-build 0.13.1 cmake 3.22.2 ninja 1.10.2.3

build_screen_dump.txt

benbovy commented 2 years ago

Thanks for the report @rbrtmch, and sorry for the wait. I could reproduce this. The recursion error is likely due to a bug or incompatibility with the last version(s) of numpy (f2py). I need to investigate this more, but in the meantime it should work with numpy 1.20.x (maybe 1.21.x).

tth030 commented 2 years ago

Hi Robert @rbrtmch , Benoit @benbovy , Did you by chance fix this issue? I have a similar issue (on mac M1 2021) and would be happy to follow up on the solution.

benbovy commented 2 years ago

I've tracked down the issue, which happens between numpy version 1.22.0 and 1.22.1.

It looks like F2PY generates incorrect signature file for a reason that I currently ignore. With 1.22.1 or later there are problematic entries where nx and ny are swaped, e.g.,

integer, optional,check(shape(stack, 0) == nx * ny),depend(ny,stack) :: nx=shape(stack, 0) / ny
integer, optional,check(shape(stack, 0) == nx * ny),depend(nx,stack) :: ny=shape(stack, 0) / nx

Whereas it should be

integer, optional,check(shape(stack, 0) == nx * ny),depend(ny,stack) :: nx=shape(stack, 0) / nx
integer, optional,check(shape(stack, 0) == nx * ny),depend(nx,stack) :: ny=shape(stack, 0) / ny

Maybe related to https://github.com/numpy/numpy/pull/20721 as it is the only change in the related f2py source between the two versions.

Note that the conda-forge python packages (fastscapelib-f2py) are built with a numpy version <1.22.1 and they are working with the last numpy versions. If you use the stable version I'd recommend it over building from source.

benbovy commented 2 years ago

ref https://github.com/numpy/numpy/issues/21893