Skip to content

Commit

Permalink
chore: fix failing workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
loathingKernel committed Nov 29, 2024
1 parent f428b01 commit 3bc74b0
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 21 deletions.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
python-xlib>=0.33
filelock>=3.15.4
urllib3>=2.0.0,<3.0.0
vdf>=3.4
2 changes: 1 addition & 1 deletion umu/umu_consts.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
from enum import Enum, StrEnum
from enum import Enum
from pathlib import Path


Expand Down
7 changes: 4 additions & 3 deletions umu/umu_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
40 changes: 24 additions & 16 deletions umu/umu_util.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -12,12 +11,12 @@
from shutil import which
from subprocess import PIPE, STDOUT, Popen, TimeoutExpired
from tarfile import open as taropen
from typing import Optional

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


Expand Down Expand Up @@ -260,60 +259,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))
Expand Down

0 comments on commit 3bc74b0

Please sign in to comment.