Croco_pytools : f2py build broken since Feb 6 due to setuptools update – temporary workaround

Hello,
Since Feb 6, our conda environment no longer works when compiling Fortran extensions with f2py.
This is due to a recent setuptools release (>= 81.0 on 6 february), which breaks the f2py build process (Fortran extensions fail to compile, even though the toolchain worked before). Downgrading setuptools fixes the problem.

Here is a quick fix (temporary workaround) :
In croco_pytools/env.yml, pin setuptools to a version < 81.0, for example:

dependencies:
  - setuptools<81.0

or after environment creation, if you use conda :
conda install "setuptools<81.0"

This restores normal f2py compilation behavior.

1 Like

Hi, thank you for the workaround but it only works on pytools version 2.0.1.

The newer ones 2.0.2 and 2.0.3 still fail with a rank mismatch error.

Hi Konstantinos,

thanks for testing this and for the feedback. On our side, with setuptools<81.0 pinned, we do not reproduce the rank mismatch error with pytools 2.0.2 or 2.0.3 — f2py extensions compile and run as expected.

To help us understand the difference, could you please confirm:

  • your Python version

  • NumPy version

  • exact setuptools version after pinning

  • compiler (gfortran version)

  • platform (OS version)

If possible, the error traceback would also be helpful.

There may be an additional dependency interaction beyond setuptools, and this information should allow us to reproduce the issue.

Hi @Konstantinos_K

I reproduced the rank mismatch error. when I shift it to Intel it is solved and created toolsf.cpython-39-x86_64-linux-gnu.so . still thinking about mpiifort/mpiifx.

changed in Makedefs :


# Fortran compilers (FC is set by conda’s compilers package)

F77 = ifort
F90 = ifort
F95 = ifort
CC  = icc
CXX = icpc

# f2py for Python-Fortran interface

F2PY = f2py

# NetCDF configuration

NETCDFINC = $(shell nf-config --includedir)
NETCDFLIB = $(shell nf-config --flibs)

# Fortran flags

FFLAGS = -fPIC
F2PY_F90FLAGS = -fPIC
F2PY_LIBS =

and in Makefile :

# compile flags (??? they used .inc :) )
CPPFLAGS = $(shell nf-config --fflags)


# lib flags 
LDFC = $(NETCDFLIB)

# program name
PROGRAM = toolsf
MOD = ./*.o

# source files
SRCS = tools_fort.F

all: $(SRCS)
        $(F90) -P -fpp $(CPPFLAGS) $(SRCS) -o tools_fort_.f

Thank you!

Hi Konstantinos,

I had this kind of issue.
Did you made a new conda/mamba croco_pyenv environnement (ex croco_pyenv_203), using the env.yml ( + downgrade specific setuptools as mentionned above) when you tried 2.0.2 or 2.0.3 ?
On my side, it fixed the rank mismatch error.

Thanks for your feedbacks.
Cheers,
Gildas

Hi, @gcambon @Konstantinos_K
Build toolsf module WITHOUT numpy or f2py (setuptools 82.0.0 or greater than)
build_pure_new.py (5.0 KB)
Currently I haven’t found any errors yet. I saw someone deleted my last post. I don’t know why. if it’s useful or not?
I hope it will work.
merci