BUG: avoid invalid Meson identifiers for f2py libraries#31963
Merged
Conversation
HaoZeke
requested changes
Jul 12, 2026
HaoZeke
left a comment
Member
There was a problem hiding this comment.
Thanks for this @VectorPeak.
#26634 only handled dots so scalapack-openmpi wouldn't work.
Separating the meson id from the -l makes sense.
I'd like a regression test to demonstrate the linker still gets -l and then this should be done :)
Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
VectorPeak
force-pushed
the
fix-f2py-meson-lib-identifiers
branch
from
July 12, 2026 17:01
b15b0c6 to
17c9b1c
Compare
Co-authored-by: chatgpt-codex-connector[bot] <199175422+chatgpt-codex-connector[bot]@users.noreply.github.com>
Contributor
Author
|
Thanks @HaoZeke, I updated the regression test to check the generated Meson dependency declarations. It now includes |
HaoZeke
approved these changes
Jul 12, 2026
HaoZeke
left a comment
Member
There was a problem hiding this comment.
Thanks @VectorPeak, LGTM, in it goes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR summary
Fixes #31964.
Fixes invalid Meson variable names generated by the f2py Meson backend for
-llibraries whose names are valid linker library names but are not valid Meson identifiers.#26634 handled dotted library names by replacing
.with_, but other inputs can still break or become ambiguous when the raw library name is used as the Meson variable name. For example, a library such asscalapack-openmpican lead to an invalid assignment target in the generatedmeson.build.This PR separates the internal Meson variable name from the user-provided linker library name. The generated dependency variable now uses a private indexed identifier, while the linker argument still preserves the original value, e.g.
-lscalapack-openmpiremains-lscalapack-openmpi.The regression test parses the generated
meson.buildand asserts that the generated dependency declarations preserve the original-l<name>linker arguments, while the unsafe original library names are not used directly as Meson assignment targets. It covers dotted, hyphenated, realistic hyphenated, underscore/collision, and digit-leading library names:foo.barscalapack-openmpifoo-barfoo_bar1fooValidation performed locally:
git diff --checkspin lintMesonTemplateparser check usingmesonbuild.mparser.Parser(...).parse(), which completed withparse-okand verified that generated dependency declarations preserve the original-l...arguments.I also attempted the focused pytest command below, but this unbuilt local source checkout stops during NumPy test configuration before selected tests run because the generated
numpy.versionmodule is unavailable:First time committer introduction
N/A.
AI Disclosure
Codex was used to investigate the failing f2py/Meson code path, draft the small code and regression-test change, run focused local validation, and draft this PR description. The diff and submission were reviewed by a human before opening the PR.