Skip to content
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

programs: Store the project version when overriding find_program #13714

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

Conversation

nirbheek
Copy link
Member

When we're using the output of configure_file() with override_find_program(), we weren't storing the version anywhere, so get_version() was trying to run the script during setup.

This is usually fine, except in cases where the configure_file() script actually has to import a library built as part of the project, and fails to run.

For built executables, we simply use the project version, and we now do the same here too.

When we're using the output of configure_file() with
override_find_program(), we weren't storing the version anywhere, so
get_version() was trying to run the script during setup.

This is usually fine, except in cases where the configure_file()
script actually has to import a library built as part of the project,
and fails to run.

For built executables, we simply use the project version, and we
now do the same here too.
@@ -340,6 +340,12 @@ class OverrideProgram(ExternalProgram):

"""A script overriding a program."""

def __init__(self, *args: T.Any, version: str, **kwargs: T.Any) -> None:
self.version = version
Copy link
Member

Choose a reason for hiding this comment

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

The parent class already defines self.cached_version so perhaps we should reuse that here. :)

@@ -340,6 +340,12 @@ class OverrideProgram(ExternalProgram):

"""A script overriding a program."""

def __init__(self, *args: T.Any, version: str, **kwargs: T.Any) -> None:
Copy link
Member

Choose a reason for hiding this comment

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

I know it's verbose, but I really want to stop using Any for things. Any instructs mypy to "ignore any errors" it's like in C writing everything as int and void* and hoping that things work out at runtime.

Copy link
Member

@eli-schwartz eli-schwartz Sep 27, 2024

Choose a reason for hiding this comment

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

At least for kwargs it is possible to pass typing_extensions.Unpack[My_TypedDict]. I can't remember what the state of the art might be for args, if anything.

It's a dissatisfying experience, compared to how e.g. generics work.

Copy link
Member

Choose a reason for hiding this comment

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

Indeed, what you really want is to be able to use a ParamSpec like you can for decorators, ie:

P = typing.ParamSepc('P')

def __init__(self, *args: P.args, version: str, **kwargs: P.kwargs) -> None:
    self.version = version
    super().__init__(*args, **kwargs)

Of course, that doesn't work...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants