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

Skip to content

BUG: f2py cannot find Fortran Compiler correctly while using flang #22910

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
helloworld664 opened this issue Jan 1, 2023 · 1 comment · Fixed by #24532
Closed

BUG: f2py cannot find Fortran Compiler correctly while using flang #22910

helloworld664 opened this issue Jan 1, 2023 · 1 comment · Fixed by #24532

Comments

@helloworld664
Copy link

helloworld664 commented Jan 1, 2023

Describe the issue:

When I use flang to compile RTTOV-11.3 with f2py, it will report a compilation ERROR: numpy.distutils.fcompiler.CompilerNotFound. But before the ERROR, it also prints: Found executable /path/to/compiler/bin/flang.

Reproduce the code example:

export FC=flang
f2py -c --help-fcompiler

Error message:

In "Fortran compilers found" part, it will print:

  --fcompiler=gnu95  GNU Fortran 95 compiler (12.0.0)

Actually, "12.0.0" is flang compiler's version, not GNU95's. So if I specify fcompiler as "flang", numpy will raise CompilerNotFound EXCEPTION. So I have to specify fcompiler as "gnu95" to continue to compile RTTOV.

Runtime information:

Found executable /path/to/compiler/bin/flang
Traceback (most recent call last):
  File "/path/to/python3/bin/f2py", line 8, in <module>
    sys.exit(main())
  File "/path/to/python3/lib/python3.6/site-packages/numpy/f2py/f2py2e.py", line 692, in main
    run_compile()
  File "/path/to/python3/lib/python3.6/site-packages/numpy/f2py/f2py2e.py", line 659, in run_compile
    setup(ext_modules=[ext])
  File "/path/to/python3/lib/python3.6/site-packages/numpy/distutils/core.py", line 169, in setup
    return old_setup(**new_attr)
  File "/path/to/python3/lib/python3.6/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/path/to/python3/lib/python3.6/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/path/to/python3/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/path/to/python3/lib/python3.6/site-packages/numpy/distutils/command/build.py", line 40, in run
    old_build.run(self)
  File "/path/to/python3/lib/python3.6/distutils/command/build.py", line 135, in run
    self.run_command(cmd_name)
  File "/path/to/python3/lib/python3.6/distutils/cmd.py", line 313, in run_command
    self.distribution.run_command(command)
  File "/path/to/python3/lib/python3.6/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/path/to/python3/lib/python3.6/site-packages/numpy/distutils/command/build_ext.py", line 238, in run
    if fcompiler and fcompiler.get_version():
  File "/path/to/python3/lib/python3.6/site-packages/numpy/distutils/fcompiler/__init__.py", line 428, in get_version
    raise CompilerNotFound()
numpy.distutils.fcompiler.CompilerNotFound
make[1]: *** [Makefile:56: ../.././/lib/rttov_gui_f2py.so] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/path/to/RTTOV-11.3/src/gui'
make: *** [Makefile:163: gui/bin] Error 2

Context for the issue:

No response

@HaoZeke
Copy link
Member

HaoZeke commented Feb 11, 2023

Thanks for the report!

Is flang able to compile a fortran-c project independently? Additionally, distutils is deprecated and adding new compilers is extremely unlikely at this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants