Skip to content

BUG: F2PY: module name not written to signature file (regression) #25263

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
jmrohwer opened this issue Nov 28, 2023 · 4 comments · Fixed by #25267
Closed

BUG: F2PY: module name not written to signature file (regression) #25263

jmrohwer opened this issue Nov 28, 2023 · 4 comments · Fixed by #25267

Comments

@jmrohwer
Copy link
Contributor

Describe the issue:

With the latest development version, the module information is not written to the signature file (*.pyf) when using f2py -h. This causes errors further down the line. It was working in v.1.26.

Reproduce the code example:

**hi.f**
      SUBROUTINE HELLO()
      PRINT*,"Hello from fortran"
      END

>>> python -m numpy.f2py -m hi -h hi.pyf hi.f

Error message:

No error message, but the hi.pyf files differ:

** hi.pyf ** (generated with numpy 2.0.0.dev)
!    -*- f90 -*-
! Note: the context of this file is case sensitive.

subroutine hello ! in hi.f
end subroutine hello

! This file was auto-generated with f2py (version:2.0.0.dev0+git20231124.94bc564).
! See:
! https://web.archive.org/web/20140822061353/http://cens.ioc.ee/projects/f2py2e

** hi.pyf ** (generated with numpy 1.26)
!    -*- f90 -*-
! Note: the context of this file is case sensitive.

python module hi ! in 
    interface  ! in :hi
        subroutine hello ! in :hi:hi.f
        end subroutine hello
    end interface 
end python module hi

! This file was auto-generated with f2py (version:1.26.1).
! See:
! https://web.archive.org/web/20140822061353/http://cens.ioc.ee/projects/f2py2e

Runtime information:

>>> numpy.show_runtime()
[{'numpy_version': '2.0.0.dev0+git20231124.94bc564',
  'python': '3.12.0 (main, Oct 21 2023, 12:40:24) [GCC 13.2.1 20230801]',
  'uname': uname_result(system='Linux', node='jr-xps13', release='6.1.63-1-MANJARO', version='#1 SMP PREEMPT_DYNAMIC Mon Nov 20 12:57:36 UTC 2023', machine='x86_64')},
 {'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
                      'found': ['SSSE3',
                                'SSE41',
                                'POPCNT',
                                'SSE42',
                                'AVX',
                                'F16C',
                                'FMA3',
                                'AVX2',
                                'AVX512F',
                                'AVX512CD',
                                'AVX512_SKX',
                                'AVX512_CLX',
                                'AVX512_CNL',
                                'AVX512_ICL'],
                      'not_found': ['AVX512_KNL', 'AVX512_KNM', 'AVX512_SPR']}},
 {'filepath': '/usr/lib/libgomp.so.1.0.0',
  'internal_api': 'openmp',
  'num_threads': 8,
  'prefix': 'libgomp',
  'user_api': 'openmp',
  'version': None}]

Context for the issue:

Building Fortran extension modules.

@HaoZeke
Copy link
Member

HaoZeke commented Nov 28, 2023

Yikes, will get to this ASAP, this should have definitely been caught by unit tests somewhere... Thanks for the report @jmrohwer.

@HaoZeke
Copy link
Member

HaoZeke commented Nov 28, 2023

This is (again) linked to the different code paths in run_main and run_compile (#25179), since:

python -m numpy.f2py -m hi hi.f -c
❯ python -c "import hi; print(hi.hello())"
 Hello from fortran

The bug was somewhere between 1.26.2 and main. So should be not too hard to narrow down.

!    -*- f90 -*-
! Note: the context of this file is case sensitive.

python module hi ! in 
    interface  ! in :hi
        subroutine hello ! in :hi:hi.f
        end subroutine hello
    end interface 
end python module hi

! This file was auto-generated with f2py (version:1.26.2).
! See:
! https://web.archive.org/web/20140822061353/http://cens.ioc.ee/projects/f2py2e

@HaoZeke
Copy link
Member

HaoZeke commented Nov 28, 2023

Narrowed it down to 9140edd

HaoZeke added a commit to HaoZeke/numpy that referenced this issue Nov 28, 2023
Co-authored-by: jmrohwer <jmrohwer@users.noreply.github.com>
HaoZeke added a commit to HaoZeke/numpy that referenced this issue Nov 28, 2023
@HaoZeke
Copy link
Member

HaoZeke commented Nov 28, 2023

Fixed in #25267. @jmrohwer I added you as a co-commit author on the test, let me know if that's not OK.

HaoZeke added a commit to HaoZeke/numpy that referenced this issue Nov 28, 2023
HaoZeke added a commit to HaoZeke/numpy that referenced this issue Nov 28, 2023
HaoZeke added a commit to HaoZeke/numpy that referenced this issue Nov 28, 2023
charris pushed a commit that referenced this issue Nov 30, 2023
* TST: Add one for gh-25263

Co-authored-by: jmrohwer <jmrohwer@users.noreply.github.com>

* BUG: Handle modules correctly for F77

Closes gh-25263

---------

Co-authored-by: jmrohwer <jmrohwer@users.noreply.github.com>
charris pushed a commit to charris/numpy that referenced this issue Dec 23, 2023
)

* TST: Add one for numpygh-25263

Co-authored-by: jmrohwer <jmrohwer@users.noreply.github.com>

* BUG: Handle modules correctly for F77

Closes numpygh-25263

---------

Co-authored-by: jmrohwer <jmrohwer@users.noreply.github.com>
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