Skip to content

Allow .version() to be called for overridden executables #14543

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sp1ritCS
Copy link
Contributor

@sp1ritCS sp1ritCS commented May 1, 2025

Right now, the set of available methods depends on the type of object returned by find_program. Specifically it fails if you attempt to call version on it, if it was an Executable put there with meson.override_find_program.

This also makes it possible that .get_version() can be called on the output of _find_tool by the modules (which is kind of required for #14422 [not really, as the returned value should never be an executable; but the mypy can't know that]).

For now this only uses the version of the subproject that called override_find_program but an additional version kwarg for meson.override_find_program could be added if required (at least from the Executable side, not sure about ExternalProgram)

@sp1ritCS sp1ritCS requested a review from jpakkane as a code owner May 1, 2025 17:37
@sp1ritCS sp1ritCS force-pushed the override-executable branch from c2f155f to 3ea8415 Compare May 1, 2025 17:50
@bonzini
Copy link
Collaborator

bonzini commented May 1, 2025

For now this only uses the version of the subproject that called override_find_program

I think that's smart and qualifies this patch as more of a bugfix than a feature.

@bonzini bonzini added the bug label May 1, 2025
@bonzini bonzini added this to the 1.9 milestone May 1, 2025
@sp1ritCS sp1ritCS force-pushed the override-executable branch from 3ea8415 to fa6bf44 Compare May 1, 2025 18:13
Copy link
Member

@eli-schwartz eli-schwartz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now this only uses the version of the subproject that called override_find_program but an additional version kwarg for meson.override_find_program could be added if required (at least from the Executable side, not sure about ExternalProgram)

This is probably "usually correct", but while less common there are projects that have separate version numbers for a library and a program that are built together.

We can infer versions of a dependency from the project version but there is still a way to annotate them with an explicit version. There's not currently a way to do that for an executable though! (And of course we can't run it with the --version flag at setup time.)

@sp1ritCS
Copy link
Contributor Author

sp1ritCS commented May 1, 2025

This is probably "usually correct", but while less common there are projects that have separate version numbers for a library and a program that are built together.

I know, thats why I mentioned the possibility of having a version kwarg for meson.override_find_program (@jpakkane mentioned to me that there was already work on exactly that kwarg some time ago, but it seemingly fizzled out and I didn't find it).

Right now it is linked to subproject version regardless of this PR or not, as if you do find_program(..., version: '>= XXX') the version guard already checks only against the subproject version.

@sp1ritCS sp1ritCS force-pushed the override-executable branch from fa6bf44 to 30e47ba Compare May 1, 2025 20:39
Also ensure that .get_version() can be called on the output of
_find_tool by the modules (kind of required for mesonbuild#14422).
@sp1ritCS sp1ritCS force-pushed the override-executable branch from 30e47ba to 52aeaa0 Compare May 1, 2025 20:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants