|
| 1 | +# pupgui2 compatibility tools module |
| 2 | +# pythonlover02's Proton-Sarek |
| 3 | +# Copyright (C) 2025 DavidoTek, partially based on AUNaseef's protonup |
| 4 | + |
| 5 | +from typing import Callable |
| 6 | + |
| 7 | + |
| 8 | +from PySide6.QtCore import QCoreApplication |
| 9 | + |
| 10 | +from pupgui2.util import fetch_project_release_data, fetch_project_releases |
| 11 | + |
| 12 | +from pupgui2.resources.ctmods.ctmod_00protonge import CtInstaller as GEProtonInstaller |
| 13 | + |
| 14 | + |
| 15 | +CT_NAME = 'Proton-Sarek' |
| 16 | +CT_LAUNCHERS = ['steam', 'lutris', 'heroicproton', 'bottles', 'advmode'] |
| 17 | +CT_DESCRIPTION = {'en': QCoreApplication.instance().translate('ctmod_protonsarek', '''A custom Proton build with <a href="https://github.com/pythonlover02/DXVK-Sarek">DXVK-Sarek</a> for users with GPUs that support Vulkan 1.1+ but not Vulkan 1.3, or for those with non-Vulkan support who want a plug-and-play option featuring personal patches.''')} |
| 18 | + |
| 19 | + |
| 20 | +class CtInstaller(GEProtonInstaller): |
| 21 | + |
| 22 | + BUFFER_SIZE = 65536 |
| 23 | + CT_URL = 'https://api.github.com/repos/pythonlover02/Proton-Sarek/releases' |
| 24 | + CT_INFO_URL = 'https://github.com/pythonlover02/Proton-Sarek/releases/tag/' |
| 25 | + |
| 26 | + def __init__(self, main_window = None) -> None: |
| 27 | + |
| 28 | + super().__init__(main_window) |
| 29 | + |
| 30 | + self.release_format: str = 'tar.gz' |
| 31 | + self.async_suffix = '-async' |
| 32 | + |
| 33 | + def fetch_releases(self, count: int = 100, page: int = 1) -> list[str]: |
| 34 | + |
| 35 | + """ |
| 36 | + List available releases |
| 37 | + Return Type: str[] |
| 38 | + """ |
| 39 | + |
| 40 | + include_extra_asset: Callable[..., list[str]] = lambda release: [str(release.get('tag_name', '')) + self.async_suffix for asset in release.get('assets', {}) if self.async_suffix in asset.get('name', '')] |
| 41 | + return fetch_project_releases(self.CT_URL, self.rs, count=count, page=page, include_extra_asset=include_extra_asset) |
| 42 | + |
| 43 | + def __fetch_github_data(self, tag: str) -> dict: |
| 44 | + |
| 45 | + """ |
| 46 | + Fetch GitHub release information |
| 47 | + Return Type: dict |
| 48 | + Content(s): |
| 49 | + 'version', 'date', 'download', 'size' |
| 50 | + """ |
| 51 | + |
| 52 | + # Exclude async builds by default -- Maybe 'get_download_url_from_asset' needs to be stricter? |
| 53 | + asset_condition = lambda asset: self.async_suffix in asset['name'] if self.async_suffix in tag else self.async_suffix not in asset['name'] |
| 54 | + return fetch_project_release_data(self.CT_URL, self.release_format, self.rs, tag=tag.replace(self.async_suffix, ''), asset_condition=asset_condition) |
| 55 | + |
| 56 | + def get_info_url(self, version: str) -> str: |
| 57 | + |
| 58 | + """ |
| 59 | + Get link with info about version (eg. GitHub release page) |
| 60 | + Return Type: str |
| 61 | + """ |
| 62 | + |
| 63 | + return super().get_info_url(version.replace(self.async_suffix, '')) |
0 commit comments