Lutris-Wine: Simplify by inheriting GE-Proton #498
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.
Overview
This PR simplifies the Lutris-Wine Ctmod by inheriting from GE-Proton. This is in a similar vein to what has been done recently with other Ctmods (#491, #494, #486).
In testing, this did not break any functionality when downloading GE-Proton for Steam or Lutris, and Lutris-Wine can still be downloaded as normal. I tested:
Implementation
GE-Proton Ctmod Changes
Some code in GE-Proton was rearranged to make this inheritance possible. Since Lutris-Wine requires a different extract directory name based on the GitHub data (we build the directory name partially from
data['version'
), we now fetch this data and return the extract directory name in a new method in the GE-Proton Ctmod called__get_data
. This calls__fetch_github_data
and returns to use the data and theprotondir
that we expect to extract.Lutris-Wine Ctmod Changes
A lot of logic is repeated between the GE-Proton Ctmod and Lutris-Wine Ctmod; download and extract, as well as the boilerplate for download progress and such, is all the same. The notable methods we have to override are:
fetch_releases
- Because we have some additional logic to includefshack
as separate versions. Thefshack
builds are a release asset as part of a single release (release assets are files attached to a release, so we pick off thefshack
archives on a release and list them separately).__fetch_github_data
- Because we need special logic to say "if we selected an fshack version to download (is_fshack
), skip any releases that don't havefshack-
in their name"util#fetch_project_release_data
here and give it anasset_condition
that facilitates thefshack
logic__fetch_data
- Because the benefit of implementing it in the GE-Proton Ctmod was to give us a "hook" for child classes to make modifications to the data and/or directory name, so overriding it allows us to specify our customprotondir
name.get_info_url
- This fixes a bug I noticed while testing that also occurs onmain
when pressing the "Info" button on an fshack release. Because this works based on tag, it tries to look forlutris-7.2-fshack
tag, which doesn't exist since fshack builds are release assets and not dedicated releases with dedicated tags. To fix this, we removefshack-
from our version string before passing it to the GE-Proton Ctmod'sget_info_url
.super().get_info_url
call, we would've just did something likereturn self.CT_URL + version.replace('fshack-', '')
. But since I noticed it while working on this PR I thought I would fix it in the scope of this PR, and so the implementation was done this way by overriding the GE-Protonget_info_url
:-)Though GE-Proton doesn't use methods like
util#fetch_project_release_data
, even if it did we would still need to override here I think, because we would want to create a customasset_condition
. The only change would be that we could structure the code more like this:Since if GE-Proton didn't need an asset condition theoretically it would also look like
return fetch_project_release_data(self.CT_URL, self.release_format, self.rs, tag=tag)
. It is a tiny bit cleaner, but not a whole lot :-)However it is worth noting that GE-Proton could use that helper function, the main reason it can't from what I recalled from being in the code again is that GE-Proton needs to get a checksum file and we don't have that functionality right now. If the
data
returned fromfetch_project_release_data
could give usdata['checksum']
, then GE-Proton could move over to it ;-)Future Work
I noticed while implementing this that Python now has an
@override
decorator, which I really like. It makes it clearer when reading which methods are overrides from their parent class, helps readibility a lot imo. I've included them in this PR, and will find time to go back and do this to other instances where we override methods if it is desired :-)Once again, the main benefit here is to reduce duplicated code where we can help it, and it should help pave the way to moving towards a base Ctmod. If we can consolidate Ctmods to have as little repeated code as possible, and only have them implement the custom logic that they need, it should help us begin to see what needs to go into a base Ctmod.
As usual, all feedback is welcome. Thanks! :-)