8000 BUG: f2py - Invalid command line options do not warn or error on Python 3.12 · Issue #24874 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content
BUG: f2py - Invalid command line options do not warn or error on Python 3.12 #24874
Closed
@2sn

Description

@2sn

Describe the issue:

In python 3.12 there seems to be an issue with directory handling that is not present in 3.11. In the very least it does behave differently. It seems to be ignoring some path specifications as well and created files in directories where there were none before, ignoring path specifications. Same numpy version, only difference is Python 3.12 instead of 3.11.6.

Likely related to meson backend, and that I use a runtime parameter combination that may not have been used/tested before/otherwise.

Maybe this can be fixed easily by someone familiar with the meson backend.
(or advise what I am doing wrong - that said, it does work with Python 3.11 and compatibility may be preferable)

Reproduce the code example:

my calls are

f2py3 --verbose -m _interface -h /home/alex/python/source/multistar/_build/_interface.pyf --f2cmap /home/alex/python/source/multistar/.f2py_f2cmap interface.f90 --overwrite-signature

then
```shell
f2py3 --verbose --build-dir /home/alex/python/source/multistar/_build --f90flags="-fPIC -fno-second-underscore -O3 -funroll-loops -fconvert=big-endian -I /home/alex/python/source/multistar/_library" --f77flags="-fPIC -fno-second-underscore -O3 -funroll-loops -fconvert=big-endian -I /home/alex/python/source/multistar/_library" --f2cmap /home/alex/python/source/multistar/.f2py_f2cmap -c -m _interface /home/alex/python/source/multistar/_library/library.a interface.f90 /home/alex/python/source/multistar/_build/_interface.pyf


### Error message:

```shell
f2py3 --verbose -m _interface -h /home/alex/python/source/multistar/_build/_interface.pyf --f2cmap /hom
7AEF
e/alex/python/source/multistar/.f2py_f2cmap interface.f90 --overwrite-signature
Reading f2cmap from '/home/alex/python/source/multistar/.f2py_f2cmap' ...
        Mapping "real(kind=real32)" to "float"
        Mapping "real(kind=real64)" to "double"
        Mapping "real(kind=real128)" to "long_double"
        Mapping "integer(kind=int8)" to "signed_char"
        Mapping "integer(kind=int16)" to "short"
        Mapping "integer(kind=int32)" to "int"
        Mapping "integer(kind=int64)" to "long"
        Mapping "integer(kind=int128)" to "long_long"
        Mapping "complex(kind=comp32)" to "complex_float"
        Mapping "complex(kind=comp64)" to "complex_double"
        Mapping "complex(kind=comp128)" to "complex_long_double"
        Mapping "character(kind=char8)" to "char"
Successfully applied user defined f2cmap changes
Reading fortran codes...
        Reading file 'interface.f90' (format:free)
(...)
In: :_interface:interface.f90:get_deriv_flags_
get_useparameters: no module typedef info used by get_deriv_flags_
In: :_interface:interface.f90:get_deriv_flags_
get_useparameters: no module flags_data info used by get_deriv_flags_
Applying post-processing hooks...
  character_backward_compatibility_hook
Post-processing (stage 2)...
Saving signatures to file "/home/alex/python/source/multistar/_build/_interface.pyf"
Stopping. Edit the signature file and then run f2py on the signature file: f2py3 /home/alex/python/source/multistar/_build/_interface.pyf

second command:
---------------

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.htmlReading f2cmap from '/home/alex/python/source/multistar/.f2py_f2cmap' ...
        Mapping "real(kind=real32)" to "float"
        Mapping "real(kind=real64)" to "double"
        Mapping "real(kind=real128)" to "long_double"
        Mapping "integer(kind=int8)" to "signed_char"
        Mapping "integer(kind=int16)" to "short"
        Mapping "integer(kind=int32)" to "int"
        Mapping "integer(kind=int64)" to "long"
        Mapping "integer(kind=int128)" to "long_long"
        Mapping "complex(kind=comp32)" to "complex_float"
        Mapping "complex(kind=comp64)" to "complex_double"
        Mapping "complex(kind=comp128)" to "complex_long_double"
        Mapping "character(kind=char8)" to "char"
Successfully applied user defined f2cmap changes
Reading fortran codes...
        Reading file 'interface.f90' (format:free)
        Reading file '/home/alex/python/source/multistar/_build/_interface.pyf' (format:free)
Post-processing...
        Block: _interface
                        Block: set_verbose_
In: :_interface:interface.f90:set_verbose_
get_useparameters: no module typedef info used by set_verbose_
In: :_interface:interface.f90:set_verbose_
(...)
get_useparameters: no module deriv_data info used by get_deriv_data_
                        Block: set_deriv_flags_
In: :_interface:interface.f90:set_deriv_flags_
get_useparameters: no module typedef info used by set_deriv_flags_
In: :_interface:interface.f90:set_deriv_flags_
get_useparameters: no module flags_data info used by set_deriv_flags_
                        Block: get_deriv_flags_
In: :_interface:interface.f90:get_deriv_flags_
get_useparameters: no module typedef info used by get_deriv_flags_
In: :_interface:interface.f90:get_deriv_flags_
get_useparameters: no module flags_data info used by get_deriv_flags_
                        Block: _interface
                                        Block: set_verbose_
In: :_interface:/home/alex/python/source/multistar/_build/_interface.pyf:_interface:unknown_interface:set_verbose_
get_useparameters: no module typedef info used by set_verbose_
In: :_interface:/home/alex/python/source/multistar/_build/_interface.pyf:_interface:unknown_interface:set_verbose_
get_useparameters: no module parameters info used by set_verbose_
                                        Block: get_verbose_
(...)
In: :_interface:/home/alex/python/source/multistar/_build/_interface.pyf:_interface:unknown_interface:set_deriv_flags_
get_useparameters: no module typedef info used by set_deriv_flags_
In: :_interface:/home/alex/python/source/multistar/_build/_interface.pyf:_interface:unknown_interface:set_deriv_flags_
get_useparameters: no module flags_data info used by set_deriv_flags_
                                        Block: get_deriv_flags_
In: :_interface:/home/alex/python/source/multistar/_build/_interface.pyf:_interface:unknown_interface:get_deriv_flags_
get_useparameters: no module typedef info used by get_deriv_flags_
In: :_interface:/home/alex/python/source/multistar/_build/_interface.pyf:_interface:unknown_interface:get_deriv_flags_
get_useparameters: no module flags_data info used by get_deriv_flags_
Applying post-processing hooks...
  character_backward_compatibility_hook
Post-processing (stage 2)...
Building modules...
    Building module "_interface"...
    Generating possibly empty wrappers"
    Maybe empty "_interface-f2pywrappers.f"
        Constructing wrapper function "set_verbose_"...
          set_verbose_(verbose)
    Generating possibly empty wrappers"
    Maybe empty "_interface-f2pywrappers.f"
        Constructing wrapper function "get_verbose_"...
          verbose = get_verbose_()
    Generating possibly empty wrappers"
    Maybe empty "_interface-f2pywrappers.f"
        Constructing wrapper function "get_status_"...
          status,status_stars = get_status_()
    Generating possibly empty wrappers"
    Maybe empty "_interface-f2pywrappers.f"
        Constructing wrapper function "reset_status_"...
          reset_status_()
    Generating possibly empty wrappers"
    Maybe empty "_interface-f2pywrappers2.f90"
    Maybe empty "_interface-f2pywrappers.f"
                Creating wrapper for Fortran subroutine "set_interact_"("set_interact_")...
        Constructing wrapper function "set_interact_"...
          set_interact_(interact)
(...)
    Maybe empty "_interface-f2pywrappers.f"
        Constructing wrapper function "get_star_data_"...
          dd = get_star_data_(tt,[nstar,nd])
    Generating possibly empty wrappers"
    Maybe empty "_interface-f2pywrappers.f"
        Constructing wrapper function "get_deriv_data_"...
          dd = get_deriv_data_(tt,yy,nv,mode)
    Generating possibly empty wrappers"
    Maybe empty "_interface-f2pywrappers.f"
        Constructing wrapper function "set_deriv_flags_"...
          old_flags = set_deriv_flags_(flags)
    Generating possibly empty wrappers"
    Maybe empty "_interface-f2pywrappers.f"
        Constructing wrapper function "get_deriv_flags_"...
          flags = get_deriv_flags_()
    Wrote C/API module "_interface" to file "./_interfacemodule.c"
    Fortran 90 wrappers are saved to "./_interface-f2pywrappers2.f90"
Traceback (most recent call last):
  File "/home/alex/Python/bin/f2py3", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/home/alex/Python/lib/python3.12/site-packages/numpy/f2py/f2py2e.py", line 732, in main
    run_compile()
  File "/home/alex/Python/lib/python3.12/site-packages/numpy/f2py/f2py2e.py", line 705, in run_compile
    builder.compile()
  File "/home/alex/Python/lib/python3.12/site-packages/numpy/f2py/_backends/_meson.py", line 129, in compile
    self.sources = _prepare_sources(self.modulename, self.sources, self.build_dir)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/alex/Python/lib/python3.12/site-packages/numpy/f2py/_backends/_meson.py", line 140, in _prepare_sources
    shutil.copy(source, bdir)
  File "/home/alex/Python/lib/python3.12/shutil.py", line 423, in copy
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/home/alex/Python/lib/python3.12/shutil.py", line 240, in copyfile
    raise SameFileError("{!r} and {!r} are the same file".format(src, dst))
shutil.SameFileError: '/home/alex/python/source/multistar/_build/_interface.pyf' and '/home/alex/python/source/multistar/_build/_interface.pyf' are the same file

Runtime information:

1.26.0
3.12.0 (main, Oct 7 2023, 10:56:13) [GCC 13.2.1 20230728 (Red Hat 13.2.1-1)]

Python 3.12 built from source on Fedora 38, numpy installed from pip.

Context for the issue:

My f2py module no longer compiles. Can't use Python 3.12.

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

      0