pwtools
pwtools copied to clipboard
Update build system to support Python 3.12 and f2py using meson
Starting with Python 3.12, f2py enforces using meson instead of the deprecated distutils as the backend. This breaks our f2py call in the Makefile.
The build of _flib fails
gfortran -I_flib.cpython-312-x86_64-linux-gnu.so.p -I. -I.. -I/usr/lib/python3/dist-packages/numpy/core/include -I/usr/lib/python3/dist-packages/numpy/f2py/src -I/usr/include/python3.12 -I/usr/include/x86_64-linux-gnu/python3.12 -fvisibility=hidden -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -O3 -fPIC -J_flib.cpython-312-x86_64-linux-gnu.so.p -o _flib.cpython-312-x86_64-linux-gnu.so.p/flib.f90.o -c ../flib.f90
../flib.f90:152:2:
152 | #define stdout 6
| 1
Warning: Illegal preprocessor directive
[...]
../flib.f90:224:24:
224 | write(stderr,*) this, "ERROR: illegal value for 'use_m'"
| 1
Error: Symbol ‘stderr’ at (1) has no IMPLICIT type
It looks like none of our compiler options passed to f2py, including F90FLAGS
, are getting through, in particular -x f95-cpp-input
to handle preprocessor statements.
Seems like a quick fix is to adopt the new(?) CLI interface to pass those options (see https://numpy.org/doc/stable/f2py/buildtools/distutils-to-meson.html). For Python < 3.11, we'd need to use f2py ... --backend meson
then.
Maybe take this opportunity to check of we can replace the custom setup.py + Makefile workflow altogether.