-
-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Description
Describe the issue:
Prior to changes in 2.2.0, the following works:
python -m numpy.f2py -m mod1 dummy.f90
with dummy.f90
having:
module mod1
implicit none
type :: master_data
integer :: idat
end type master_data
type(master_data) :: masterdata
end module mod1
subroutine simple_subroutine(arg)
use mod1
integer, intent(inout) :: arg
arg = arg * 5
end subroutine simple_subroutine
It worked before 2.2.0, since the module is in a use
statement, it is skipped.
With changes in 2.2.0, only modules with a common
block are skipped, and this case is not. Running the above fails when trying to interpret the derived type master_data
with the error below:
Reproduce the code example:
python -m numpy.f2py -m mod1 dummy.f90
Error message:
getctype: No C-type found in "{'typespec': 'type', 'typename': 'master_data'}", assuming void.
Traceback (most recent call last):
File "{path}/bin/f2py", line 8, in <module>
sys.exit(main())
^^^^^^
File "{path}/lib/python3.12/site-packages/numpy/f2py/f2py2e.py", line 783, in main
run_main(sys.argv[1:])
File "{{path}}/lib/python3.12/site-packages/numpy/f2py/f2py2e.py", line 507, in run_main
ret = buildmodules(postlist)
^^^^^^^^^^^^^^^^^^^^^^
File "{{path}}/lib/python3.12/site-packages/numpy/f2py/f2py2e.py", line 412, in buildmodules
dict_append(ret[name], rules.buildmodule(module, um))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "{{path}}/lib/python3.12/site-packages/numpy/f2py/rules.py", line 1317, in buildmodule
mr, wrap = f90mod_rules.buildhooks(m)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "{{path}}/lib/python3.12/site-packages/numpy/f2py/f90mod_rules.py", line 149, in buildhooks
at = capi_maps.c2capi_map[ct]
~~~~~~~~~~~~~~~~~~~~^^^^
KeyError: 'void'
Python and NumPy Versions:
2.2.0 (and above)
3.12.10 | packaged by conda-forge | (main, Apr 10 2025, 22:21:13) [GCC 13.3.0]
Runtime Environment:
[{'numpy_version': '2.2.0',
'python': '3.12.10 | packaged by conda-forge | (main, Apr 10 2025, 22:21:13) '
'[GCC 13.3.0]',
'uname': uname_result(system='Linux', node='gs66', release='5.15.0-303.171.5.2.1.el8uek.x86_64', version='#2 SMP Mon Dec 23 14:37:50 PST 2024', 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']}}]
Context for the issue:
Changes to f2py in 2.2.0 broke code that used to compile before