Describe the issue:
The f2py Meson backend currently derives Meson variable identifiers from -l library names. #26634 fixed one instance of this by replacing dots with underscores, but other linker-valid library names can still produce invalid or ambiguous Meson identifiers.
For example, a library name such as scalapack-openmpi is valid as a linker argument (-lscalapack-openmpi) but is not valid as a Meson assignment target if used directly as the generated variable name:
scalapack-openmpi = declare_dependency(link_args : ['-lscalapack-openmpi'])
Meson rejects that because the assignment target must be an identifier. Similar problems can occur for names beginning with digits, and multiple different library names can collapse to the same underscore form if sanitization is not made unique.
A proposed fix is open in #31963. It generates private indexed Meson identifiers while preserving the original -l<name> linker arguments.
Reproduce the code example:
A representative f2py invocation is:
f2py -c module.f90 -lscalapack-openmpi --backend meson
The relevant call chain is:
f2py CLI args
-> run_compile() extracts -l entries into libraries
-> MesonBackend.write_meson_build()
-> MesonTemplate.libraries_substitution()
-> generated meson.build lib_declarations/lib_list
Error message:
Meson can reject the generated meson.build with a parse error similar to:
ParseException: Assignment target must be an id.
Python and NumPy Versions:
Observed on the current NumPy development branch while inspecting the generated f2py Meson backend output. This is a source-generation issue and does not depend on a completed NumPy build.
Runtime Environment:
Windows local checkout; the affected generated Meson syntax is platform-independent.
Describe the issue:
The f2py Meson backend currently derives Meson variable identifiers from
-llibrary names. #26634 fixed one instance of this by replacing dots with underscores, but other linker-valid library names can still produce invalid or ambiguous Meson identifiers.For example, a library name such as
scalapack-openmpiis valid as a linker argument (-lscalapack-openmpi) but is not valid as a Meson assignment target if used directly as the generated variable name:Meson rejects that because the assignment target must be an identifier. Similar problems can occur for names beginning with digits, and multiple different library names can collapse to the same underscore form if sanitization is not made unique.
A proposed fix is open in #31963. It generates private indexed Meson identifiers while preserving the original
-l<name>linker arguments.Reproduce the code example:
A representative f2py invocation is:
The relevant call chain is:
Error message:
Meson can reject the generated
meson.buildwith a parse error similar to:Python and NumPy Versions:
Observed on the current NumPy development branch while inspecting the generated f2py Meson backend output. This is a source-generation issue and does not depend on a completed NumPy build.
Runtime Environment:
Windows local checkout; the affected generated Meson syntax is platform-independent.