-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
base: master
Are you sure you want to change the base?
Conversation
dfb8067
to
abdba2b
Compare
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.
abdba2b
to
aa0efb9
Compare
@@ -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 |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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...
When we're using the output of
configure_file()
withoverride_find_program()
, we weren't storing the version anywhere, soget_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.