Package: python3-numpy Version: 1:1.26.4+ds-11 Severity: normal X-Debbugs-Cc: stefanosimonucci....@alice.it
Dear Maintainer, I use f2py to use fortran subroutines from python scripts. With meson backend I am having problems, when I link object files to create extension modules. I report the following simplified example. I have two files: provamod.f90 subroutine pp(x,y) implicit none double precision x,y y=sin(x) end subroutine and provasub.f90 subroutine func(x,f) !f2py intent(in) x !f2py intent(out) f implicit none double precision x,f call pp(x,f) end subroutine The compilation is the following gfortran -c provamod.f90 <enter> ls provamod* <enter> provamod.f90 provamod.o f2py -c -m prova provasub.f90 provamod.o <enter> Cannot use distutils backend with Python>=3.12, using meson backend instead. Using meson backend Will pass --lower to f2py See https://numpy.org/doc/stable/f2py/buildtools/meson.html Reading fortran codes... Reading file 'provasub.f90' (format:free) Post-processing... Block: prova Block: func Applying post-processing hooks... character_backward_compatibility_hook Post-processing (stage 2)... Building modules... Building module "prova"... Generating possibly empty wrappers" Maybe empty "prova-f2pywrappers.f" Constructing wrapper function "func"... f = func(x) Wrote C/API module "prova" to file "./provamodule.c" The Meson build system Version: 1.5.1 Source dir: /tmp/tmpumsqkcku Build dir: /tmp/tmpumsqkcku/bbdir Build type: native build Project name: prova Project version: 0.1 Fortran compiler for the host machine: gfortran (gcc 13.3.0 "GNU Fortran (Debian 13.3.0-3) 13.3.0") Fortran linker for the host machine: gfortran ld.bfd 2.43 C compiler for the host machine: cc (gcc 13.3.0 "cc (Debian 13.3.0-3) 13.3.0") C linker for the host machine: cc ld.bfd 2.43 Host machine cpu family: x86_64 Host machine cpu: x86_64 Program /usr/bin/python3 found: YES (/usr/bin/python3) Found pkg-config: YES (/usr/bin/pkg-config) 1.8.1 Run-time dependency python found: YES 3.12 Library quadmath found: YES Build targets in project: 1 Found ninja-1.12.1 at /usr/bin/ninja INFO: autodetecting backend as ninja INFO: calculating backend command to run: /usr/bin/ninja -C /tmp/tmpumsqkcku/bbdir ninja: Entering directory `/tmp/tmpumsqkcku/bbdir' [6/6] Linking target prova.cpython-312-x86_64-linux-gnu.so ls prova* <enter> prova.cpython-312-x86_64-linux-gnu.so provamod.o provasub.f90 provamod.f90 Now I start python and I get: python3 <enter> Python 3.12.4 (main, Jul 15 2024, 12:17:32) [GCC 13.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> >>> import prova Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: /home/stefano/Downloads/prova/prova.cpython-312-x86_64-linux-gnu.so: undefined symbol: pp_ >>> It looks like the object file was not loaded. I get the same thing if I indicate the path of the object file f2py -c -m prova provasub.f90 $(pwd)/provamod.o Cannot use distutils backend with Python>=3.12, using meson backend instead. Using meson backend Will pass --lower to f2py See https://numpy.org/doc/stable/f2py/buildtools/meson.html Reading fortran codes... Reading file 'provasub.f90' (format:free) Post-processing... Block: prova Block: func Applying post-processing hooks... character_backward_compatibility_hook Post-processing (stage 2)... Building modules... Building module "prova"... Generating possibly empty wrappers" Maybe empty "prova-f2pywrappers.f" Constructing wrapper function "func"... f = func(x) Wrote C/API module "prova" to file "./provamodule.c" The Meson build system Version: 1.5.1 Source dir: /tmp/tmp3jiab8oq Build dir: /tmp/tmp3jiab8oq/bbdir Build type: native build Project name: prova Project version: 0.1 Fortran compiler for the host machine: gfortran (gcc 13.3.0 "GNU Fortran (Debian 13.3.0-3) 13.3.0") Fortran linker for the host machine: gfortran ld.bfd 2.43 C compiler for the host machine: cc (gcc 13.3.0 "cc (Debian 13.3.0-3) 13.3.0") C linker for the host machine: cc ld.bfd 2.43 Host machine cpu family: x86_64 Host machine cpu: x86_64 Program /usr/bin/python3 found: YES (/usr/bin/python3) Found pkg-config: YES (/usr/bin/pkg-config) 1.8.1 Run-time dependency python found: YES 3.12 Library quadmath found: YES Build targets in project: 1 Found ninja-1.12.1 at /usr/bin/ninja INFO: autodetecting backend as ninja INFO: calculating backend command to run: /usr/bin/ninja -C /tmp/tmp3jiab8oq/bbdir ninja: Entering directory `/tmp/tmp2jiab8oq/bbdir' [6/6] Linking target prova.cpython-312-x86_64-linux-gnu.so python3 Python 3.12.4 (main, Jul 15 2024, 12:17:32) [GCC 13.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import prova Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: /home/stefano/Downloads/prova/prova.cpython-312-x86_64-linux-gnu.so: undefined symbol: pp_ >>> Only the complete compilation works: f2py -c -m prova provasub.f90 provamod.f90 Cannot use distutils backend with Python>=3.12, using meson backend instead. Using meson backend Will pass --lower to f2py See https://numpy.org/doc/stable/f2py/buildtools/meson.html Reading fortran codes... Reading file 'provasub.f90' (format:free) Reading file 'provamod.f90' (format:free) Post-processing... Block: prova Block: func Block: pp Applying post-processing hooks... character_backward_compatibility_hook Post-processing (stage 2)... Building modules... Building module "prova"... Generating possibly empty wrappers" Maybe empty "prova-f2pywrappers.f" Constructing wrapper function "func"... f = func(x) Generating possibly empty wrappers" Maybe empty "prova-f2pywrappers.f" Constructing wrapper function "pp"... pp(x,y) Wrote C/API module "prova" to file "./provamodule.c" The Meson build system Version: 1.5.1 Source dir: /tmp/tmpr_f2k6hu Build dir: /tmp/tmpr_f2k6hu/bbdir Build type: native build Project name: prova Project version: 0.1 Fortran compiler for the host machine: gfortran (gcc 13.3.0 "GNU Fortran (Debian 13.3.0-3) 13.3.0") Fortran linker for the host machine: gfortran ld.bfd 2.43 C compiler for the host machine: cc (gcc 13.3.0 "cc (Debian 13.3.0-3) 13.3.0") C linker for the host machine: cc ld.bfd 2.43 Host machine cpu family: x86_64 Host machine cpu: x86_64 Program /usr/bin/python3 found: YES (/usr/bin/python3) Found pkg-config: YES (/usr/bin/pkg-config) 1.8.1 Run-time dependency python found: YES 3.12 Library quadmath found: YES Build targets in project: 1 Found ninja-1.12.1 at /usr/bin/ninja INFO: autodetecting backend as ninja INFO: calculating backend command to run: /usr/bin/ninja -C /tmp/tmpr_f2k6hu/bbdir ninja: Entering directory `/tmp/tmpr_f2k6hu/bbdir' [7/7] Linking target prova.cpython-312-x86_64-linux-gnu.so python3 Python 3.12.4 (main, Jul 15 2024, 12:17:32) [GCC 13.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import prova >>> I have never encountered this difficulty before (with distutils). I also tried to transform the object into provamod.a library and then link it also indicating -L$(pwd) but it doesn't work. Thank you in advance Stefano -- System Information: Debian Release: trixie/sid APT prefers stable-updates APT policy: (500, 'stable-updates'), (500, 'stable-security'), (500, 'testing'), (500, 'stable') Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 6.9.12-amd64 (SMP w/8 CPU threads; PREEMPT) Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE Locale: LANG=it_IT.UTF-8, LC_CTYPE=it_IT.UTF-8 (charmap=UTF-8), LANGUAGE not set Shell: /bin/sh linked to /usr/bin/dash Init: systemd (via /run/systemd/system) LSM: AppArmor: enabled Versions of packages python3-numpy depends on: ii libatlas3-base [liblapack.so.3] 3.10.3-14 ii libblas3 [libblas.so.3] 3.12.0-3 ii libc6 2.39-6 ii libgcc-s1 14-20240330-1 ii liblapack3 [liblapack.so.3] 3.12.0-3 ii libopenblas0-pthread [liblapack.so.3] 0.3.27+ds-2 ii python3 3.12.4-1 ii python3-pkg-resources 70.3.0-2 python3-numpy recommends no packages. Versions of packages python3-numpy suggests: ii gcc 4:13.2.0-7 ii gfortran 4:13.2.0-7 pn python-numpy-doc <none> ii python3-dev 3.12.4-1 pn python3-pytest <none> -- no debconf information