8000 BUG: Bad meson code generated by f2py with dotted library · Issue #26623 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

BUG: Bad meson code generated by f2py with dotted library #26623

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
mathomp4 opened this issue Jun 5, 2024 · 0 comments · Fixed by #26634
Closed

BUG: Bad meson code generated by f2py with dotted library #26623

mathomp4 opened this issue Jun 5, 2024 · 0 comments · Fixed by #26634

Comments

@mathomp4
Copy link
Contributor
mathomp4 commented Jun 5, 2024

Describe the issue:

I'm having an issue trying to build a code using f2py with meson (aka Python 3.12). To wit, I have an f2py code that depends on a library libMAPL.base.so. When I try and use f2py with it, I get this error from Meson:

The Meson build system
Version: 1.4.1
Source dir: /tmp/tmpzxxmb51m
Build dir: /tmp/tmpzxxmb51m/bbdir
Build type: native build

meson.build:35:10: ERROR: Expecting lparen got assign.
MAPL.base = declare_dependency(link_args : ['-lMAPL.base'])
          ^

I believe the issue is that Meson thinks that MAPL.base is a method of the MAPL object or something? (I do not know Meson.)

You can reproduce this with the code below (saved as qsat_py.F90) running with:

f2py -m qsat_  -lMAPL.base --build-dir ./foo -c qsat_py.F90

Reproduce the code example:

subroutine qsat ( qs, T, p, nobs )
  use MAPL_SatVaporMod, only: MAPL_EQsat

  integer, intent(in) :: nobs
  real,    intent(in) :: p(nobs) ! pressure in Pa
  real,    intent(in) :: T(nobs) ! dry-bulb temperature in K
  real,    intent(out) :: qs(nobs) ! saturation specific humidity
  integer i

  do i = 1, nobs
     qs(i) = MAPL_EQsat(TL=t(i),PL=p(i),OverIce=.True.)
  end do
end subroutine qsat

subroutine qsatnoice ( qs, T, p, nobs )
  use MAPL_SatVaporMod, only: MAPL_EQsat

  integer, intent(in) :: nobs
  real,    intent(in) :: p(nobs) ! pressure in Pa
  real,    intent(in) :: T(nobs) ! dry-bulb temperature in K
  real,    intent(out) :: qs(nobs) ! saturation specific humidity
  integer i

  do i = 1, nobs
     qs(i) = MAPL_EQsat(TL=t(i),PL=p(i),OverIce=.False.)
  end do
end subroutine qsatnoice

Error message:

The Meson build system
Version: 1.4.1
Source dir: /tmp/tmpzxxmb51m
Build dir: /tmp/tmpzxxmb51m/bbdir
Build type: native build

meson.build:35:10: ERROR: Expecting lparen got assign.
MAPL.base = declare_dependency(link_args : ['-lMAPL.base'])
          ^

A full log can be found at /tmp/tmpzxxmb51m/bbdir/meson-logs/meson-log.txt
Traceback (most recent call last):
  File "/usr/local/other/GEOSpyD/24.4.0-0_py3.12/2024-05-31/bin/f2py", line 10, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/other/GEOSpyD/24.4.0-0_py3.12/2024-05-31/lib/python3.12/site-packages/numpy/f2py/f2py2e.py", line 766, in main
    run_compile()
  File "/usr/local/other/GEOSpyD/24.4.0-0_py3.12/2024-05-31/lib/python3.12/site-packages/numpy/f2py/f2py2e.py", line 738, in run_compile
    builder.compile()
  File "/usr/local/other/GEOSpyD/24.4.0-0_py3.12/2024-05-31/lib/python3.12/site-packages/numpy/f2py/_backends/_meson.py", line 178, in compile
    self.run_meson(self.build_dir)
  File "/usr/local/other/GEOSpyD/24.4.0-0_py3.12/2024-05-31/lib/python3.12/site-packages/numpy/f2py/_backends/_meson.py", line 171, in run_meson
    self._run_subprocess_command(setup_command, build_dir)
  File "/usr/local/other/GEOSpyD/24.4.0-0_py3.12/2024-05-31/lib/python3.12/site-packages/numpy/f2py/_backends/_meson.py", line 167, in _run_subprocess_command
    subprocess.run(command, cwd=cwd, check=True)
  File "/usr/local/other/GEOSpyD/24.4.0-0_py3.12/2024-05-31/lib/python3.12/subprocess.py", line 571, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['meson', 'setup', 'bbdir']' returned non-zero exit status 1.

Python and NumPy Versions:

1.26.4
3.12.2 | packaged by conda-forge | (main, Feb 16 2024, 20:50:58) [GCC 12.3.0]

Runtime Environment:

[{'numpy_version': '1.26.4',
'python': '3.12.2 | packaged by conda-forge | (main, Feb 16 2024, 20:50:58) '
'[GCC 12.3.0]',
'uname': uname_result(system='Linux', node='discover33', release='5.14.21-150400.24.81-default', version='#1 SMP PREEMPT_DYNAMIC Tue Aug 8 14:10:43 UTC 2023 (90a74a8)', machine='x86_64')},
{'simd_extensions': {'baseline': ['SSE', 'SSE2', 'SSE3'],
'found': ['SSSE3',
'SSE41',
'POPCNT',
'SSE42',
'AVX',
'F16C',
'FMA3',
'AVX2'],
'not_found': ['AVX512F',
'AVX512CD',
'AVX512_KNL',
'AVX512_KNM',
'AVX512_SKX',
'AVX512_CLX',
'AVX512_CNL',
'AVX512_ICL',
'AVX512_SPR']}},
{'filepath': '/gpfsm/dulocal15/sles15/other/GEOSpyD/24.4.0-0_py3.12/2024-05-31/lib/libmkl_rt.so.2',
'internal_api': 'mkl',
'num_threads': 1,
'prefix': 'libmkl_rt',
'threading_layer': 'intel',
'user_api': 'blas',
'version': '2023.2-Product'},
{'filepath': '/gpfsm/dulocal15/sles15/other/GEOSpyD/24.4.0-0_py3.12/2024-05-31/lib/libomp.so',
'internal_api': 'openmp',
'num_threads': 1,
'prefix': 'libomp',
'user_api': 'openmp',
'version': None}]

Context for the issue:

We cannot move to Python 3.12 unless we can work around this. Is there someway to have f2py "mangle" the variables it constructs in meson?

HaoZeke added a commit to mathomp4/numpy that referenced this issue Jun 9, 2024
On creating incorrect meson.build files

Co-authored-by: mathomp4 <mathomp4@users.noreply.github.com>
charris pushed a commit to charris/numpy that referenced this issue Jun 10, 2024
On creating incorrect meson.build files

Co-authored-by: mathomp4 <mathomp4@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.

2 participants
0