Change get_installer_runner_version() back to returning None if versions are not supported.

We had a bug where has_runner_versions was not being set; it's safer if you can just override this one method to support these.
This commit is contained in:
Daniel Johnson 2024-03-01 19:27:54 -05:00
parent f3d6b55418
commit 87dadb7410
7 changed files with 22 additions and 27 deletions

View file

@ -11,7 +11,6 @@ gi.require_version("PangoCairo", "1.0")
import cairo
from gi.repository import Gdk, GLib, GObject, Gtk, Pango, PangoCairo
from lutris.exceptions import MissingMediaError
from lutris.gui.widgets.utils import (
MEDIA_CACHE_INVALIDATED,
get_default_icon_path,

View file

@ -1,6 +1,5 @@
from gi.repository import Gtk
from lutris.exceptions import MissingMediaError
from lutris.gui.widgets.utils import (
ICON_SIZE,
get_default_icon_path,

View file

@ -34,19 +34,20 @@ class CommandsMixin:
"""Return absolute path of wine version used during the installation, but
None if the wine exe can't be located."""
runner = self.get_runner_class(self.installer.runner)()
try:
version = runner.get_installer_runner_version(self.installer, use_runner_config=False)
except (UnspecifiedVersionError, RuntimeError):
# Special case that lets the Wine configuration explicit specify the path
# to the Wine executable, not just a version number.
if self.installer.runner == "wine":
try:
config_version, runner_config = wine.get_runner_version_and_config()
return get_wine_path_for_version(config_version, config=runner_config.runner_level)
except UnspecifiedVersionError:
pass
version = runner.get_installer_runner_version(self.installer, use_runner_config=False)
if version:
return get_wine_path_for_version(version)
version = get_default_wine_version()
# Special case that lets the Wine configuration explicit specify the path
# to the Wine executable, not just a version number.
if self.installer.runner == "wine":
try:
config_version, runner_config = wine.get_runner_version_and_config()
return get_wine_path_for_version(config_version, config=runner_config.runner_level)
except UnspecifiedVersionError:
pass
version = get_default_wine_version()
return get_wine_path_for_version(version)
def get_runner_class(self, runner_name):

View file

@ -275,7 +275,7 @@ class ScriptInterpreter(GObject.Object, CommandsMixin):
try:
runner.install(
ui_delegate,
version=runner.get_installer_runner_version(self.installer) if runner.has_runner_versions else None,
version=runner.get_installer_runner_version(self.installer),
callback=install_more_runners,
)
except (NonInstallableRunnerError, RunnerInstallationError) as ex:

View file

@ -67,7 +67,6 @@ class libretro(Runner):
runnable_alone = True
runner_executable = "retroarch/retroarch"
flatpak_id = "org.libretro.RetroArch"
has_runner_versions = True
game_options = [
{"option": "main_file", "type": "file", "label": _("ROM file")},

View file

@ -2,7 +2,7 @@
import os
import signal
from gettext import gettext as _
from typing import Callable, Dict
from typing import Callable, Dict, Optional
from lutris import runtime, settings
from lutris.api import format_runner_version, get_default_runner_version_info
@ -35,7 +35,6 @@ class Runner: # pylint: disable=too-many-public-methods
download_url = None
arch = None # If the runner is only available for an architecture that isn't x86_64
flatpak_id = None
has_runner_versions = False
def __init__(self, config=None):
"""Initialize runner."""
@ -451,8 +450,8 @@ class Runner: # pylint: disable=too-many-public-methods
script settings, to determine more precisely what must be installed."""
return self.is_installed()
def get_installer_runner_version(self, installer, use_runner_config: bool = True) -> str:
raise RuntimeError("The '%s' runner does not support versions" % self.name)
def get_installer_runner_version(self, installer, use_runner_config: bool = True) -> Optional[str]:
return None
def get_runner_version(self, version: str = None) -> Dict[str, str]:
"""Get the appropriate version for a runner, as with get_default_runner_version(),

View file

@ -3,7 +3,7 @@
import os
import shlex
from gettext import gettext as _
from typing import Dict, Tuple
from typing import Dict, Optional, Tuple
from lutris import runtime, settings
from lutris.api import format_runner_version
@ -163,7 +163,6 @@ class wine(Runner):
platforms = [_("Windows")]
multiple_versions = True
entry_point_option = "exe"
has_runner_versions = True
game_options = [
{
@ -782,7 +781,9 @@ class wine(Runner):
except MisconfigurationError:
return False
def get_installer_runner_version(self, installer, use_runner_config: bool = True, use_api: bool = False) -> str:
def get_installer_runner_version(
self, installer, use_runner_config: bool = True, use_api: bool = False
) -> Optional[str]:
# If a version is specified in the script choose this one
version = None
if installer.script.get(installer.runner):
@ -802,7 +803,7 @@ class wine(Runner):
try:
return wine.get_runner_version_and_config()[0]
except UnspecifiedVersionError:
pass # prefer the error message below for this
pass # fall back to the API in this case
if not version and use_api:
# Try to obtain the default wine version from the Lutris API.
@ -811,9 +812,6 @@ class wine(Runner):
logger.debug("Default wine version is %s", default_version_info["version"])
version = format_runner_version(default_version_info)
if not version:
raise UnspecifiedVersionError(_("The installer does not specify a Wine version."))
return version
@classmethod