From 18b6b7ec086bd679f30e6c722aeb5db9dc46db83 Mon Sep 17 00:00:00 2001 From: Stelios Tsampas Date: Fri, 29 Nov 2024 21:48:21 +0200 Subject: [PATCH] chore: fix failing workflows --- pyproject.toml | 2 +- requirements.in | 1 + umu/umu_consts.py | 2 +- umu/umu_run.py | 7 ++++--- umu/umu_util.py | 41 +++++++++++++++++++++++++---------------- 5 files changed, 32 insertions(+), 21 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c23624f4e..aaf064298 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -35,7 +35,7 @@ classifiers = [ urls = { repository = "https://github.com/Open-Wine-Components/umu-launcher" } # Note: urllib3 is a vendored dependency. When using our Makefile, it will be # installed automatically. -dependencies = ["python-xlib>=0.33", "filelock>=3.9.0", "urllib3>=2.0.0,<3.0.0", "vdf>=3.4.0"] +dependencies = ["python-xlib>=0.33", "filelock>=3.9.0", "urllib3>=2.0.0,<3.0.0", "vdf>=3.4"] [project.optional-dependencies] # Recommended diff --git a/requirements.in b/requirements.in index 49ce05aec..3e6b5a6a8 100644 --- a/requirements.in +++ b/requirements.in @@ -1,3 +1,4 @@ python-xlib>=0.33 filelock>=3.15.4 urllib3>=2.0.0,<3.0.0 +vdf>=3.4 diff --git a/umu/umu_consts.py b/umu/umu_consts.py index 786d6c8b5..9acb36720 100644 --- a/umu/umu_consts.py +++ b/umu/umu_consts.py @@ -1,5 +1,5 @@ import os -from enum import Enum, StrEnum +from enum import Enum from pathlib import Path diff --git a/umu/umu_run.py b/umu/umu_run.py index febb9fd50..1ffd8a3e9 100755 --- a/umu/umu_run.py +++ b/umu/umu_run.py @@ -50,13 +50,13 @@ from umu.umu_proton import get_umu_proton from umu.umu_runtime import setup_umu from umu.umu_util import ( + CompatibilityTool, + SteamRuntime, get_libc, get_library_paths, has_umu_setup, is_installed_verb, xdisplay, - SteamRuntime, - CompatibilityTool ) NET_TIMEOUT = 5.0 @@ -311,7 +311,8 @@ def build_command( """Build the command to be executed.""" shim: Path = local.joinpath("umu-shim") entry_point: Path = local.joinpath("umu") - if opts is None: opts = [] + if opts is None: + opts = [] # Exit if the entry point is missing # The _v2-entry-point script and container framework tools are included in diff --git a/umu/umu_util.py b/umu/umu_util.py index 63623b0db..cfbc57e72 100644 --- a/umu/umu_util.py +++ b/umu/umu_util.py @@ -1,7 +1,6 @@ import os -import sys import shlex -import vdf +import sys from contextlib import contextmanager from ctypes.util import find_library from functools import lru_cache @@ -12,12 +11,13 @@ from shutil import which from subprocess import PIPE, STDOUT, Popen, TimeoutExpired from tarfile import open as taropen -from typing import Optional +from typing import Any +import vdf from urllib3.response import BaseHTTPResponse from Xlib import display -from umu.umu_consts import UMU_LOCAL, RUNTIME_VERSIONS +from umu.umu_consts import RUNTIME_VERSIONS, UMU_LOCAL from umu.umu_log import log @@ -260,60 +260,69 @@ def has_umu_setup(path: Path = UMU_LOCAL) -> bool: class SteamBase: + """Base class describing runtime and compat tool common features.""" - def __init__(self, path: str): + def __init__(self, path: str) -> None: # noqa: D107 self.tool_path = path - with open(Path(path).joinpath("toolmanifest.vdf"), "r", encoding="utf-8") as f: + with Path(path).joinpath("toolmanifest.vdf").open(encoding="utf-8") as f: self.tool_manifest = vdf.load(f)["manifest"] @property - def required_tool_appid(self) -> Optional[str]: + def required_tool_appid(self) -> str: # noqa: D102 return self.tool_manifest.get("require_tool_appid", None) @property - def required_tool_name(self) -> Optional[str]: + def required_tool_name(self) -> None: + """Map the required tool's appid to a tuple of commonly used names.""" if self.required_tool_appid is None: return None return RUNTIME_VERSIONS[self.required_tool_appid] @property - def layer(self) -> Optional[str]: + def layer(self) -> str: # noqa: D102 return self.tool_manifest.get("compatmanager_layer_name", None) def command(self, verb: str) -> list[str]: + """Return the tool specific entry point.""" tool_path = os.path.normpath(self.tool_path) cmd = "".join([shlex.quote(tool_path), self.tool_manifest["commandline"]]) cmd = cmd.replace("_v2-entry-point", "umu") cmd = cmd.replace("%verb%", str(verb)) return shlex.split(cmd) - def as_str(self, verb: str): + def as_str(self, verb: str): # noqa: D102 return " ".join(map(shlex.quote, self.command(verb))) class SteamRuntime(SteamBase): + """A Steam Linux Runtime (soldier, sniper, medic etc).""" - def __init__(self, path: str): + def __init__(self, path: str) -> None: # noqa: D107 super().__init__(path) class CompatibilityTool(SteamBase): + """A compatibility tool (Proton, luxtorpeda, etc).""" - def __init__(self, tool_path: str, shim: Path, runtime: SteamRuntime): + def __init__(self, tool_path: str, shim: Path, runtime: SteamRuntime) -> None: # noqa: D107 super().__init__(tool_path) self.shim = shim self.runtime = runtime if self.required_tool_appid is not None else None - with open(Path(tool_path).joinpath("compatibilitytool.vdf"), "r", encoding="utf-8") as f: + with Path(tool_path).joinpath("compatibilitytool.vdf").open(encoding="utf-8") as f: # There can be multiple tools definitions in `compatibilitytools.vdf` # Take the first one and hope it is the one with the correct display_name compat_tools = tuple(vdf.load(f)["compatibilitytools"]["compat_tools"].values()) - self.compatibilitytool = compat_tools[0] + self.compatibility_tool = compat_tools[0] @property - def display_name(self) -> str: - return self.compatibilitytool["display_name"] + def display_name(self) -> str: # noqa: D102 + return self.compatibility_tool["display_name"] def command(self, verb: str) -> list[str]: + """Return the fully qualified command for the tool . + + If the tool uses a runtime, it's entry point is prepended to the tool's command. + """ cmd = self.runtime.command(verb) if self.runtime is not None else [] cmd.append(self.shim.as_posix()) cmd.extend(super().command(verb))