Skip to content

BUG: numpy.f2py cannot be used with -c and --[no-]latex-doc together. #29420

@ringobanana-3900

Description

@ringobanana-3900

Describe the issue:

When I add the --latex-doc or the --no-latex-doc option to f2py with the -c option, I get an error:

meson.build:38:3: ERROR: File --latex-doc does not exist.

Apparently, this is because --[no-]latex-doc is not recognized as an f2py option and is not removed in run_compile().

numpy/numpy/f2py/f2py2e.py

Lines 633 to 637 in ea869ec

_reg2 = re.compile(
r'--((no-|)(wrap-functions|lower|freethreading-compatible)|debug-capi|quiet|skip-empty-wrappers)|-include')
f2py_flags = [_m for _m in sys.argv[1:] if _reg2.match(_m)]
sys.argv = [_m for _m in sys.argv if _m not in f2py_flags]

Reproduce the code example:

# fib1.f is the same file as written in
# https://numpy.org/doc/stable/f2py/f2py.getting-started.html

# Using "f2py -c fib1.f -m fib1 --latex-doc" instead gave the same error.

python -m numpy.f2py -c fib1.f -m fib1 --latex-doc

Error message:

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.html
Reading fortran codes...
        Reading file 'fib1.f' (format:fix,strict)
Post-processing...
        Block: fib1
                        Block: fib
Applying post-processing hooks...
  character_backward_compatibility_hook
Post-processing (stage 2)...
Building modules...
    Building module "fib1"...
    Generating possibly empty wrappers"
    Maybe empty "fib1-f2pywrappers.f"
        Constructing wrapper function "fib"...
          fib(a,[n])
    Wrote C/API module "fib1" to file "./fib1module.c"
    Documentation is saved to file "./fib1module.tex"
The Meson build system
Version: 1.8.2
Source dir: /private/var/folders/r5/drhnr3w9343b2rcxps4fqz2c0000gn/T/tmpyszwfg4e
Build dir: /private/var/folders/r5/drhnr3w9343b2rcxps4fqz2c0000gn/T/tmpyszwfg4e/bbdir
Build type: native build
Project name: fib1
Project version: 0.1
Fortran compiler for the host machine: gfortran (gcc 15.1.0 "GNU Fortran (Homebrew GCC 15.1.0) 15.1.0")
Fortran linker for the host machine: gfortran ld64 1167.5
C compiler for the host machine: cc (clang 17.0.0 "Apple clang version 17.0.0 (clang-1700.0.13.5)")
C linker for the host machine: cc ld64 1167.5
Host machine cpu family: aarch64
Host machine cpu: aarch64
Program <MyEnvironmentDirectory>/bin/python found: YES (<MyEnvironmentDirectory>/bin/python)
Found pkg-config: YES (/opt/homebrew/bin/pkg-config) 2.5.1
Run-time dependency python found: YES 3.13
Library quadmath found: YES

meson.build:38:3: ERROR: File --latex-doc does not exist.

A full log can be found at /private/var/folders/r5/drhnr3w9343b2rcxps4fqz2c0000gn/T/tmpyszwfg4e/bbdir/meson-logs/meson-log.txt
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "<MyEnvironmentDirectory>/lib/python3.13/site-packages/numpy/f2py/__main__.py", line 5, in <module>
    main()
    ~~~~^^
  File "<MyEnvironmentDirectory>/lib/python3.13/site-packages/numpy/f2py/f2py2e.py", line 781, in main
    run_compile()
    ~~~~~~~~~~~^^
  File "<MyEnvironmentDirectory>/lib/python3.13/site-packages/numpy/f2py/f2py2e.py", line 753, in run_compile
    builder.compile()
    ~~~~~~~~~~~~~~~^^
  File "<MyEnvironmentDirectory>/lib/python3.13/site-packages/numpy/f2py/_backends/_meson.py", line 192, in compile
    self.run_meson(self.build_dir)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^
  File "<MyEnvironmentDirectory>/lib/python3.13/site-packages/numpy/f2py/_backends/_meson.py", line 185, in run_meson
    self._run_subprocess_command(setup_command, build_dir)
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<MyEnvironmentDirectory>/lib/python3.13/site-packages/numpy/f2py/_backends/_meson.py", line 181, in _run_subprocess_command
    subprocess.run(command, cwd=cwd, check=True)
    ~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<MyEnvironmentDirectory>/lib/python3.13/subprocess.py", line 577, in run
    raise CalledProcessError(retcode, process.args,
                             output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['meson', 'setup', 'bbdir']' returned non-zero exit status 1.

Python and NumPy Versions:

numpy: 2.2.6
python: 3.13.5 (main, Jul 22 2025, 13:32:59) [Clang 17.0.0 (clang-1700.0.13.5)]

Runtime Environment:

[{'numpy_version': '2.2.6',
'python': '3.13.5 (main, Jul 22 2025, 13:32:59) [Clang 17.0.0 '
'(clang-1700.0.13.5)]',
'uname': uname_result(system='Darwin', node='MacBook-Air.local', release='24.5.0', version='Darwin Kernel Version 24.5.0: Tue Apr 22 19:54:33 PDT 2025; root:xnu-11417.121.6~2/RELEASE_ARM64_T8122', machine='arm64')},
{'simd_extensions': {'baseline': ['NEON', 'NEON_FP16', 'NEON_VFPV4', 'ASIMD'],
'found': ['ASIMDHP'],
'not_found': ['ASIMDFHM']}}]

Context for the issue:

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy