From bb629d2fc5b41f50ccd9ddda0d90780b1aac9bf7 Mon Sep 17 00:00:00 2001 From: Zylquinal <80770188+Zylquinal@users.noreply.github.com> Date: Fri, 17 Feb 2023 11:24:02 +0700 Subject: [PATCH 1/9] make unspecified 'Arch' to be listed for 32-bit and 64-bit architecture, fix for #2166 --- bottles/frontend/views/bottle_dependencies.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bottles/frontend/views/bottle_dependencies.py b/bottles/frontend/views/bottle_dependencies.py index 8cdb5158b2..fd6923a0bd 100644 --- a/bottles/frontend/views/bottle_dependencies.py +++ b/bottles/frontend/views/bottle_dependencies.py @@ -130,7 +130,8 @@ def process_dependencies(): if dep[0] in self.config.Installed_Dependencies: continue # Do not list already installed dependencies' - if dep[1].get("Arch", "win64") != self.config.Arch: + dependency_arch = dep[1].get("Arch") + if dependency_arch is not None and dependency_arch != self.config.get("Arch"): # NOTE: avoid listing dependencies not supported by the bottle arch continue From 3da21681a70b10ddd96cf3ca6b59aca15939cc3e Mon Sep 17 00:00:00 2001 From: Kinsteen Date: Tue, 25 Apr 2023 19:12:58 +0200 Subject: [PATCH 2/9] Show message when dependency is not compatible with bottle arch --- bottles/frontend/views/bottle_dependencies.py | 11 +++-------- bottles/frontend/widgets/dependency.py | 7 +++++++ 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/bottles/frontend/views/bottle_dependencies.py b/bottles/frontend/views/bottle_dependencies.py index fd6923a0bd..fdf6cd8116 100644 --- a/bottles/frontend/views/bottle_dependencies.py +++ b/bottles/frontend/views/bottle_dependencies.py @@ -63,8 +63,8 @@ def __init__(self, details, config: BottleConfig, **kwargs): self.btn_report.connect("clicked", open_doc_url, "contribute/missing-dependencies") self.btn_help.connect("clicked", open_doc_url, "bottles/dependencies") - if self.manager.utils_conn.status == False: - self.stack.set_visible_child_name("page_offline") + if not self.manager.utils_conn.status: + self.stack.set_visible_child_name("page_offline") self.spinner_loading.start() @@ -128,12 +128,7 @@ def process_dependencies(): if len(dependencies.keys()) > 0: for dep in dependencies.items(): if dep[0] in self.config.Installed_Dependencies: - continue # Do not list already installed dependencies' - - dependency_arch = dep[1].get("Arch") - if dependency_arch is not None and dependency_arch != self.config.get("Arch"): - # NOTE: avoid listing dependencies not supported by the bottle arch - continue + continue # Do not list already installed dependencies GLib.idle_add(new_dependency, dep) diff --git a/bottles/frontend/widgets/dependency.py b/bottles/frontend/widgets/dependency.py index d50932be48..e137925861 100644 --- a/bottles/frontend/widgets/dependency.py +++ b/bottles/frontend/widgets/dependency.py @@ -67,6 +67,13 @@ def __init__(self, window, config: BottleConfig, dependency, plain=False, **kwar self.btn_reinstall.set_visible(True) return + if self.config.Arch not in dependency[1].get("Arch", "win64_win32"): + self.btn_install.set_visible(False) + self.btn_remove.set_visible(False) + self.btn_reinstall.set_visible(False) + self.btn_err.set_visible(True) + self.btn_err.set_tooltip_text(_("This dependency is not compatible with this bottle architecture.")) + # populate widgets self.set_title(dependency[0]) self.set_subtitle(dependency[1].get("Description")) From 68a94802065c66b367bb716157eec96726813053 Mon Sep 17 00:00:00 2001 From: Kinsteen Date: Tue, 25 Apr 2023 19:35:00 +0200 Subject: [PATCH 3/9] Linting --- bottles/frontend/views/bottle_dependencies.py | 10 ++++---- bottles/frontend/widgets/dependency.py | 25 ++++++++++--------- 2 files changed, 18 insertions(+), 17 deletions(-) diff --git a/bottles/frontend/views/bottle_dependencies.py b/bottles/frontend/views/bottle_dependencies.py index fdf6cd8116..9b51fe24d2 100644 --- a/bottles/frontend/views/bottle_dependencies.py +++ b/bottles/frontend/views/bottle_dependencies.py @@ -28,9 +28,9 @@ from bottles.frontend.widgets.dependency import DependencyEntry -@Gtk.Template(resource_path='/com/usebottles/bottles/details-dependencies.ui') +@Gtk.Template(resource_path="/com/usebottles/bottles/details-dependencies.ui") class DependenciesView(Adw.Bin): - __gtype_name__ = 'DetailsDependencies' + __gtype_name__ = "DetailsDependencies" __registry = [] # region Widgets @@ -89,7 +89,7 @@ def empty_list(self): r.get_parent().remove(r) self.__registry = [] - def update(self, widget=False, config: Optional[BottleConfig] = None): + def update(self, _widget=False, config: Optional[BottleConfig] = None): """ This function update the dependencies list with the supported by the manager. @@ -99,7 +99,7 @@ def update(self, widget=False, config: Optional[BottleConfig] = None): self.config = config # Not sure if it's the best place to make this check - if self.manager.utils_conn.status == False: + if not self.manager.utils_conn.status: return self.stack.set_visible_child_name("page_loading") @@ -115,7 +115,7 @@ def new_dependency(dependency, plain=False): self.list_dependencies.append(entry) @GtkUtils.run_in_main_loop - def callback(result, error=False): + def callback(_result, _error=False): self.stack.set_visible_child_name("page_deps") def process_dependencies(): diff --git a/bottles/frontend/widgets/dependency.py b/bottles/frontend/widgets/dependency.py index e137925861..4d347f7cf7 100644 --- a/bottles/frontend/widgets/dependency.py +++ b/bottles/frontend/widgets/dependency.py @@ -28,9 +28,9 @@ from bottles.frontend.windows.generic import SourceDialog -@Gtk.Template(resource_path='/com/usebottles/bottles/dependency-entry.ui') +@Gtk.Template(resource_path="/com/usebottles/bottles/dependency-entry.ui") class DependencyEntry(Adw.ActionRow): - __gtype_name__ = 'DependencyEntry' + __gtype_name__ = "DependencyEntry" # region Widgets label_category = Gtk.Template.Child() @@ -56,10 +56,10 @@ def __init__(self, window, config: BottleConfig, dependency, plain=False, **kwar self.queue = window.page_details.queue if plain: - ''' + """ If the dependency is plain, treat it as a placeholder, it can be used to display "fake" elements on the list - ''' + """ self.set_title(dependency) self.set_subtitle("") self.btn_install.set_visible(False) @@ -87,24 +87,24 @@ def __init__(self, window, config: BottleConfig, dependency, plain=False, **kwar self.btn_license.connect("clicked", self.open_license) if dependency[0] in self.config.Installed_Dependencies: - ''' + """ If the dependency is installed, hide the btn_install button and show the btn_remove button - ''' + """ self.btn_install.set_visible(False) self.btn_remove.set_visible(True) self.btn_reinstall.set_visible(True) if dependency[0] in self.config.Uninstallers.keys(): - ''' + """ If the dependency has no uninstaller, disable the btn_remove button - ''' + """ uninstaller = self.config.Uninstallers[dependency[0]] if uninstaller in [False, "NO_UNINSTALLER"]: self.btn_remove.set_sensitive(False) - def open_manifest(self, widget): + def open_manifest(self, _widget): """ This function pop up a dialog with the manifest of the dependency @@ -118,7 +118,7 @@ def open_manifest(self, widget): ) ).present() - def open_license(self, widget): + def open_license(self, _widget): """ This function pop up a dialog with the license of the dependency @@ -128,7 +128,7 @@ def open_license(self, widget): ) webbrowser.open(manifest["License_url"]) - def install_dependency(self, widget): + def install_dependency(self, _widget): """ This function install the dependency in the bottle, it will also prevent user from installing other dependencies @@ -179,7 +179,8 @@ def set_install_status(self, result: Result, error=None): self.window.show_toast(_("\"{0}\" uninstalled").format(self.dependency[0])) else: self.window.show_toast(_("\"{0}\" installed").format(self.dependency[0])) - return self.set_installed(uninstaller, removed) + self.set_installed(uninstaller, removed) + return self.set_err() def set_err(self): From 68e63093e6e75a5422beb9ce08598c604e91ffbb Mon Sep 17 00:00:00 2001 From: koplo199 <85577251+koplo199@users.noreply.github.com> Date: Wed, 27 Sep 2023 12:18:15 +0200 Subject: [PATCH 4/9] Fix missing 'for' verb handling and minor formatting issues --- bottles/backend/managers/dependency.py | 4 ++++ bottles/frontend/views/bottle_dependencies.py | 2 +- bottles/frontend/widgets/dependency.py | 4 ++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/bottles/backend/managers/dependency.py b/bottles/backend/managers/dependency.py index 6440cacb24..8a7fb31490 100644 --- a/bottles/backend/managers/dependency.py +++ b/bottles/backend/managers/dependency.py @@ -128,6 +128,10 @@ def install(self, config: BottleConfig, dependency: list) -> Result: Here we execute all steps in the manifest. Steps are the actions performed to install the dependency. """ + arch = step.get("for", "win64_win32") + if config.Arch not in arch: + continue + res = self.__perform_steps(config, step) if not res.ok: TaskManager.remove(task_id) diff --git a/bottles/frontend/views/bottle_dependencies.py b/bottles/frontend/views/bottle_dependencies.py index 9b51fe24d2..160fd9d05a 100644 --- a/bottles/frontend/views/bottle_dependencies.py +++ b/bottles/frontend/views/bottle_dependencies.py @@ -64,7 +64,7 @@ def __init__(self, details, config: BottleConfig, **kwargs): self.btn_help.connect("clicked", open_doc_url, "bottles/dependencies") if not self.manager.utils_conn.status: - self.stack.set_visible_child_name("page_offline") + self.stack.set_visible_child_name("page_offline") self.spinner_loading.start() diff --git a/bottles/frontend/widgets/dependency.py b/bottles/frontend/widgets/dependency.py index 4d347f7cf7..8613b13ca3 100644 --- a/bottles/frontend/widgets/dependency.py +++ b/bottles/frontend/widgets/dependency.py @@ -149,12 +149,12 @@ def install_dependency(self, _widget): dependency=self.dependency, ) - def remove_dependency(self, widget): + def remove_dependency(self, _widget): """ This function remove the dependency from the bottle configuration """ - widget.set_sensitive(False) + _widget.set_sensitive(False) RunAsync( task_func=self.manager.remove_dependency, callback=self.set_install_status, From 58f5755c1036b584edf9b437e28e750e8aa35c88 Mon Sep 17 00:00:00 2001 From: koplo199 <85577251+koplo199@users.noreply.github.com> Date: Sun, 1 Oct 2023 22:05:45 +0200 Subject: [PATCH 5/9] fix: vkBasalt, gamescope and MangoHud versions --- bottles/frontend/views/bottle_preferences.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bottles/frontend/views/bottle_preferences.py b/bottles/frontend/views/bottle_preferences.py index 7f5e9cb96f..2789c169b3 100644 --- a/bottles/frontend/views/bottle_preferences.py +++ b/bottles/frontend/views/bottle_preferences.py @@ -195,9 +195,9 @@ def __init__(self, details, config, **kwargs): _not_available = _("This feature is unavailable on your system.") _flatpak_not_available = _("{} To add this feature, please run flatpak install").format(_not_available) _flatpak_pkg_name = { - "gamescope": "org.freedesktop.Platform.VulkanLayer.gamescope", - "vkbasalt": "org.freedesktop.Platform.VulkanLayer.vkBasalt//22.08", - "mangohud": "org.freedesktop.Platform.VulkanLayer.MangoHud//22.08", + "gamescope": "org.freedesktop.Platform.VulkanLayer.gamescope//23.08", + "vkbasalt": "org.freedesktop.Platform.VulkanLayer.vkBasalt//23.08", + "mangohud": "org.freedesktop.Platform.VulkanLayer.MangoHud//23.08", "obsvkc": "com.obsproject.Studio.Plugin.OBSVkCapture" } From 90ee77dbd7a3b8d672fd5083380da57526312d11 Mon Sep 17 00:00:00 2001 From: koplo199 <85577251+koplo199@users.noreply.github.com> Date: Mon, 2 Oct 2023 16:06:00 +0200 Subject: [PATCH 6/9] Do not hardcode versions --- bottles/backend/globals.py | 3 ++- bottles/frontend/views/bottle_preferences.py | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bottles/backend/globals.py b/bottles/backend/globals.py index 152afd4194..3a55149d8f 100644 --- a/bottles/backend/globals.py +++ b/bottles/backend/globals.py @@ -20,7 +20,7 @@ from functools import lru_cache from pathlib import Path from typing import Dict - +from bottles.backend.utils import json @lru_cache class Paths: @@ -79,6 +79,7 @@ class TrdyPaths: mangohud_available = shutil.which("mangohud") or False obs_vkc_available = shutil.which("obs-vkcapture") or False vmtouch_available = shutil.which("vmtouch") or False +base_version = json.load(open("/app/manifest.json")).get("base-version","").removeprefix("stable-") # encoding detection correction, following windows defaults locale_encodings: Dict[str, str] = { diff --git a/bottles/frontend/views/bottle_preferences.py b/bottles/frontend/views/bottle_preferences.py index 2789c169b3..9cc93e778c 100644 --- a/bottles/frontend/views/bottle_preferences.py +++ b/bottles/frontend/views/bottle_preferences.py @@ -195,9 +195,9 @@ def __init__(self, details, config, **kwargs): _not_available = _("This feature is unavailable on your system.") _flatpak_not_available = _("{} To add this feature, please run flatpak install").format(_not_available) _flatpak_pkg_name = { - "gamescope": "org.freedesktop.Platform.VulkanLayer.gamescope//23.08", - "vkbasalt": "org.freedesktop.Platform.VulkanLayer.vkBasalt//23.08", - "mangohud": "org.freedesktop.Platform.VulkanLayer.MangoHud//23.08", + "gamescope": f"org.freedesktop.Platform.VulkanLayer.gamescope//{base_version}" if base_version else "org.freedesktop.Platform.VulkanLayer.gamescope", + "vkbasalt": f"org.freedesktop.Platform.VulkanLayer.vkBasalt//{base_version}" if base_version else "org.freedesktop.Platform.VulkanLayer.vkBasalt", + "mangohud": f"org.freedesktop.Platform.VulkanLayer.MangoHud//{base_version}" if base_version else "org.freedesktop.Platform.VulkanLayer.MangoHud", "obsvkc": "com.obsproject.Studio.Plugin.OBSVkCapture" } From ab33b21db54b60988f8f2ef3492a3c141309ae8c Mon Sep 17 00:00:00 2001 From: koplo199 <85577251+koplo199@users.noreply.github.com> Date: Mon, 2 Oct 2023 16:11:57 +0200 Subject: [PATCH 7/9] Avoid unnecessary strings duplication --- bottles/frontend/views/bottle_preferences.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/bottles/frontend/views/bottle_preferences.py b/bottles/frontend/views/bottle_preferences.py index 9cc93e778c..cc529d9ec9 100644 --- a/bottles/frontend/views/bottle_preferences.py +++ b/bottles/frontend/views/bottle_preferences.py @@ -194,11 +194,15 @@ def __init__(self, details, config, **kwargs): self.switch_vmtouch.set_sensitive(vmtouch_available) _not_available = _("This feature is unavailable on your system.") _flatpak_not_available = _("{} To add this feature, please run flatpak install").format(_not_available) + _gamescope_pkg_name = "org.freedesktop.Platform.VulkanLayer.gamescope" + _vkbasalt_pkg_name = "org.freedesktop.Platform.VulkanLayer.vkBasalt" + _mangohud_pkg_name = "org.freedesktop.Platform.VulkanLayer.MangoHud" + _obsvkc_pkg_name = "com.obsproject.Studio.Plugin.OBSVkCapture" _flatpak_pkg_name = { - "gamescope": f"org.freedesktop.Platform.VulkanLayer.gamescope//{base_version}" if base_version else "org.freedesktop.Platform.VulkanLayer.gamescope", - "vkbasalt": f"org.freedesktop.Platform.VulkanLayer.vkBasalt//{base_version}" if base_version else "org.freedesktop.Platform.VulkanLayer.vkBasalt", - "mangohud": f"org.freedesktop.Platform.VulkanLayer.MangoHud//{base_version}" if base_version else "org.freedesktop.Platform.VulkanLayer.MangoHud", - "obsvkc": "com.obsproject.Studio.Plugin.OBSVkCapture" + "gamescope": f"{_gamescope_pkg_name}//{base_version}" if base_version else _gamescope_pkg_name, + "vkbasalt": f"{_vkbasalt_pkg_name}//{base_version}" if base_version else _vkbasalt_pkg_name, + "mangohud": f"{_mangohud_pkg_name}//{base_version}" if base_version else _mangohud_pkg_name, + "obsvkc": _obsvkc_pkg_name } if not gamemode_available: From 3717f01940b2980743698e89099c47d8b24cf3ab Mon Sep 17 00:00:00 2001 From: koplo199 <85577251+koplo199@users.noreply.github.com> Date: Mon, 2 Oct 2023 16:39:11 +0200 Subject: [PATCH 8/9] Attempt to fix pytest --- bottles/backend/globals.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/bottles/backend/globals.py b/bottles/backend/globals.py index 3a55149d8f..d925125f58 100644 --- a/bottles/backend/globals.py +++ b/bottles/backend/globals.py @@ -20,7 +20,7 @@ from functools import lru_cache from pathlib import Path from typing import Dict -from bottles.backend.utils import json +from bottles.backend.utils import yaml, json @lru_cache class Paths: @@ -79,7 +79,9 @@ class TrdyPaths: mangohud_available = shutil.which("mangohud") or False obs_vkc_available = shutil.which("obs-vkcapture") or False vmtouch_available = shutil.which("vmtouch") or False -base_version = json.load(open("/app/manifest.json")).get("base-version","").removeprefix("stable-") +base_version = "" +if os.path.isfile("/app/manifest.json"): + base_version = json.load(open("/app/manifest.json")).get("base-version","").removeprefix("stable-") # encoding detection correction, following windows defaults locale_encodings: Dict[str, str] = { From bb5c5d917809210a1393b8d2a304673788724742 Mon Sep 17 00:00:00 2001 From: koplo199 <85577251+koplo199@users.noreply.github.com> Date: Tue, 3 Oct 2023 17:17:02 +0200 Subject: [PATCH 9/9] Add missing import --- bottles/frontend/views/bottle_preferences.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bottles/frontend/views/bottle_preferences.py b/bottles/frontend/views/bottle_preferences.py index cc529d9ec9..7d1454cdcf 100644 --- a/bottles/frontend/views/bottle_preferences.py +++ b/bottles/frontend/views/bottle_preferences.py @@ -23,7 +23,7 @@ from gi.repository import Gtk, Adw from bottles.backend.globals import gamemode_available, vkbasalt_available, mangohud_available, obs_vkc_available, \ - vmtouch_available, gamescope_available + vmtouch_available, gamescope_available, base_version from bottles.backend.logger import Logger from bottles.backend.managers.library import LibraryManager from bottles.backend.managers.runtime import RuntimeManager