Thanks to visit codestin.com
Credit goes to github.com

Skip to content

f2py doesn't finishing compiling #19673

@kconnour

Description

@kconnour

I have some FORTRAN code that I want to combine into a .so file and import with Python. I wrote a script that does that as part of setup.py. This script works on some computers but not others. When it fails, f2py appears to go through the entire compilation process and prints a command-line command, but it seems this command is never executed. If I manually execute this command, the compilation succeeds.

The build works on my Ubuntu 20.10 and macOS 10.15.7 computers but fails on macOS 11, but I'm not convinced this is an OS issue. In all cases I'm using gfortran from gcc 10.2.0.

Reproducing code example:

I can't give the full code without my fortran modules but this is the key f2py line.

from numpy import f2py
with open('path/to/DISORT.f') as disort:
        f2py.compile(disort.read(), modulename='disort', extra_args=mod_paths)

Error message:

None. Regardless of whether or not the build succeeds, f2py outputs something like the following near the end of its output:

/usr/local/bin/gfortran -Wall -g -Wall -g -undefined dynamic_lookup -bundle /var/folders/_2/5thyvq3j25n1_wx318h5lqf00000h8/T/tmp4g4jlqyl/var/folders/_2/5thyvq3j25n1_wx318h5lqf00000h8/T/tmp4g4jlqyl/src.macosx-11.3-x86_64-3.9/disortmodule.o /var/folders/_2/5thyvq3j25n1_wx318h5lqf00000h8/T/tmp4g4jlqyl/var/folders/_2/5thyvq3j25n1_wx318h5lqf00000h8/T/tmp4g4jlqyl/src.macosx-11.3-x86_64-3.9/fortranobject.o /var/folders/_2/5thyvq3j25n1_wx318h5lqf00000h8/T/tmp4g4jlqyl/var/folders/_2/5thyvq3j25n1_wx318h5lqf00000h8/T/tmpg2n7bma6.o /var/folders/_2/5thyvq3j25n1_wx318h5lqf00000h8/T/tmp4g4jlqyl/disort4.0.99/BDREF.o /var/folders/_2/5thyvq3j25n1_wx318h5lqf00000h8/T/tmp4g4jlqyl/disort4.0.99/DISOBRDF.o /var/folders/_2/5thyvq3j25n1_wx318h5lqf00000h8/T/tmp4g4jlqyl/disort4.0.99/ERRPACK.o /var/folders/_2/5thyvq3j25n1_wx318h5lqf00000h8/T/tmp4g4jlqyl/disort4.0.99/LAPACK.o /var/folders/_2/5thyvq3j25n1_wx318h5lqf00000h8/T/tmp4g4jlqyl/disort4.0.99/LINPAK.o /var/folders/_2/5thyvq3j25n1_wx318h5lqf00000h8/T/tmp4g4jlqyl/disort4.0.99/RDI1MACH.o /var/folders/_2/5thyvq3j25n1_wx318h5lqf00000h8/T/tmp4g4jlqyl/var/folders/_2/5thyvq3j25n1_wx318h5lqf00000h8/T/tmp4g4jlqyl/src.macosx-11.3-x86_64-3.9/disort-f2pywrappers.o -L/usr/local/lib/gcc/x86_64-apple-darwin19/10.2.0 -L/usr/local/lib/gcc/x86_64-apple-darwin19/10.2.0/../../.. -L/usr/local/lib/gcc/x86_64-apple-darwin19/10.2.0/../../.. -lgfortran -o ./disort.cpython-39-darwin.so

On some computers, f2py won't have generated a .so file. However, in every instance that this happens, if I simply copy the above command and paste it into Terminal and execute it, it does create the .so file. When it does create the .so file (without my manual intervention) I do also get a line like the following:

Removing build directory /var/folders/2w/9zwyqhw11218bmh13tp__lj0008m_6/T/tmp6_95cpvx

NumPy/Python version information:

1.20.2 3.9.5 (default, May 7 2021, 21:28:16)
[Clang 12.0.5 (clang-1205.0.22.9)]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions