Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support compatibility tools other than Proton out-of-the-box. #293

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ umu-launcher-install: umu-launcher-dist-install umu-launcher-bin-install
$(OBJDIR)/.build-umu-vendored: | $(OBJDIR)
$(info :: Building vendored dependencies )
python3 -m pip install urllib3 -t $(OBJDIR)
python3 -m pip install vdf -t $(OBJDIR)
python3 -m pip install pyzstd --config-settings="--build-option=--dynamic-link-zstd" -t $(OBJDIR)

.PHONY: umu-vendored
Expand All @@ -111,6 +112,7 @@ umu-vendored-install: umu-vendored
$(info :: Installing subprojects )
install -d $(DESTDIR)$(PYTHONDIR)/umu/_vendor
cp -r $(OBJDIR)/urllib3 $(DESTDIR)$(PYTHONDIR)/umu/_vendor
cp -r $(OBJDIR)/vdf $(DESTDIR)$(PYTHONDIR)/umu/_vendor
cp -r $(OBJDIR)/pyzstd $(DESTDIR)$(PYTHONDIR)/umu/_vendor

$(OBJDIR):
Expand Down
4 changes: 2 additions & 2 deletions 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", "urllib3>=2.0.0,<3.0.0"]
dependencies = ["python-xlib>=0.33", "urllib3>=2.0.0,<3.0.0", "vdf>=3.4"]

[project.optional-dependencies]
# Recommended
Expand Down Expand Up @@ -156,7 +156,7 @@ exclude = [
"subprojects",
]
# Same as Black.
line-length = 88
line-length = 79
indent-width = 4
target-version = "py310"

Expand Down
1 change: 1 addition & 0 deletions requirements.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
python-xlib>=0.33
urllib3>=2.0.0,<3.0.0
vdf>=3.4
xxhash>=3.2.0
pyzstd>=0.16.2
cbor2>=5.4.6
30 changes: 30 additions & 0 deletions umu/umu_consts.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
from dataclasses import dataclass
from enum import Enum
from pathlib import Path

Expand Down Expand Up @@ -93,3 +94,32 @@ class GamescopeAtom(Enum):
# Constant defined in prctl.h
# See prctl(2) for more details
PR_SET_CHILD_SUBREAPER = 36


@dataclass
class UmuRuntime:
"""Holds information about a runtime."""

name: str
version: str
path: Path | None = None

def __post_init__(self) -> None: # noqa: D105
if self.version == "native":
return
if self.path is None:
self.path = UMU_LOCAL.joinpath(self.name)
# Temporary override for backwards compatibility
if self.version == "steamrt3":
self.path = UMU_LOCAL


RUNTIME_VERSIONS = {
"host": UmuRuntime("host", "native" ),
"1070560": UmuRuntime("scout", "steamrt1"),
"1391110": UmuRuntime("soldier", "steamrt2"),
"1628350": UmuRuntime("sniper", "steamrt3"),
# "" : UmuRuntime("medic", "steamrt4"),
}

RUNTIME_NAMES = {RUNTIME_VERSIONS[key].name: key for key in RUNTIME_VERSIONS}
8 changes: 7 additions & 1 deletion umu/umu_proton.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,13 @@
from urllib3.response import BaseHTTPResponse

from umu.umu_bspatch import Content, ContentContainer, CustomPatcher
from umu.umu_consts import STEAM_COMPAT, UMU_CACHE, UMU_COMPAT, UMU_LOCAL, HTTPMethod
from umu.umu_consts import (
STEAM_COMPAT,
UMU_CACHE,
UMU_COMPAT,
UMU_LOCAL,
HTTPMethod,
)
from umu.umu_log import log
from umu.umu_util import (
extract_tarfile,
Expand Down
77 changes: 44 additions & 33 deletions umu/umu_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
from umu.umu_consts import (
PR_SET_CHILD_SUBREAPER,
PROTON_VERBS,
RUNTIME_NAMES,
RUNTIME_VERSIONS,
STEAM_COMPAT,
STEAM_WINDOW_ID,
UMU_LOCAL,
Expand All @@ -49,6 +51,7 @@
from umu.umu_proton import get_umu_proton
from umu.umu_runtime import setup_umu
from umu.umu_util import (
CompatibilityTool,
get_libc,
get_library_paths,
has_umu_setup,
Expand Down Expand Up @@ -129,7 +132,7 @@ def check_env(
env["WINEPREFIX"] = os.environ.get("WINEPREFIX", "")

# Skip Proton if running a native Linux executable
if os.environ.get("UMU_NO_PROTON") == "1":
if os.environ.get("UMU_NO_TOOL") == "1":
return env

path: Path = STEAM_COMPAT.joinpath(os.environ.get("PROTONPATH", ""))
Expand All @@ -148,6 +151,11 @@ def check_env(
os.environ["PROTONPATH"] = ""
get_umu_proton(env, session_pools)

if (key := os.environ.get("PROTONPATH")) in RUNTIME_NAMES:
os.environ["PROTONPATH"] = str(
RUNTIME_VERSIONS[RUNTIME_NAMES[key]].path
)

env["PROTONPATH"] = os.environ["PROTONPATH"]

# If download fails/doesn't exist in the system, raise an error
Expand Down Expand Up @@ -252,7 +260,7 @@ def set_env(
# Runtime
env["UMU_NO_RUNTIME"] = os.environ.get("UMU_NO_RUNTIME") or ""
env["UMU_RUNTIME_UPDATE"] = os.environ.get("UMU_RUNTIME_UPDATE") or ""
env["UMU_NO_PROTON"] = os.environ.get("UMU_NO_PROTON") or ""
env["UMU_NO_TOOL"] = os.environ.get("UMU_NO_TOOL") or ""

# Proton logging (to stdout)
# Check for PROTON_LOG because it redirects output to log file
Expand Down Expand Up @@ -298,16 +306,13 @@ def enable_steam_game_drive(env: dict[str, str]) -> dict[str, str]:
def build_command(
env: dict[str, str],
local: Path,
opts: list[str] = [],
opts: list[str] | None = None,
) -> tuple[Path | str, ...]:
"""Build the command to be executed."""
shim: Path = local.joinpath("umu-shim")
proton: Path = Path(env["PROTONPATH"], "proton")
entry_point: Path = local.joinpath("umu")

if env.get("UMU_NO_PROTON") != "1" and not proton.is_file():
err: str = "The following file was not found in PROTONPATH: proton"
raise FileNotFoundError(err)
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 All @@ -319,41 +324,47 @@ def build_command(
)
raise FileNotFoundError(err)

if env.get("UMU_NO_TOOL") == "1":
runtime = CompatibilityTool(str(RUNTIME_VERSIONS[RUNTIME_NAMES["sniper"]].path), shim)
# Will run the game within the Steam Runtime w/o Proton
# Ideally, for reliability, executables should be compiled within
# the Steam Runtime
log.debug(
"Compatibility tool disabled. Executing linux-native executable %s", env["EXE"]
)
return (
*runtime.command(env["PROTON_VERB"]),
env["EXE"],
*opts,
)

# Setup compatibility tool
# If the user explicitly requested to run without the runtime,
# force runtime to None
compat_tool = CompatibilityTool(env["PROTONPATH"], shim)
if env["UMU_NO_RUNTIME"] == "1":
compat_tool.runtime = None
log.info("Using compatibility tool %s", compat_tool.display_name)
# Will run the game outside the Steam Runtime w/ Proton
if not compat_tool.runtime_enabled:
log.warning("Runtime Platform disabled")

# Winetricks
if env.get("EXE", "").endswith("winetricks") and opts:
if compat_tool.layer != "proton":
err: str = "Winetricks is available only on Proton and Proton-derived tools"
raise ValueError(err)
# The position of arguments matter for winetricks
# Usage: ./winetricks [options] [command|verb|path-to-verb] ...
return (
entry_point,
"--verb",
env["PROTON_VERB"],
"--",
proton,
env["PROTON_VERB"],
*compat_tool.command(env["PROTON_VERB"]),
env["EXE"],
"-q",
*opts,
)

# Will run the game within the Steam Runtime w/o Proton
# Ideally, for reliability, executables should be compiled within
# the Steam Runtime
if env.get("UMU_NO_PROTON") == "1":
return (entry_point, "--verb", env["PROTON_VERB"], "--", env["EXE"], *opts)

# Will run the game outside the Steam Runtime w/ Proton
if env.get("UMU_NO_RUNTIME") == "1":
log.warning("Runtime Platform disabled")
return proton, env["PROTON_VERB"], env["EXE"], *opts

return (
entry_point,
"--verb",
env["PROTON_VERB"],
"--",
shim,
proton,
env["PROTON_VERB"],
*compat_tool.command(env["PROTON_VERB"]),
env["EXE"],
*opts,
)
Expand Down Expand Up @@ -731,7 +742,7 @@ def umu_run(args: Namespace | tuple[str, list[str]]) -> int:
"UMU_ZENITY": "",
"UMU_NO_RUNTIME": "",
"UMU_RUNTIME_UPDATE": "",
"UMU_NO_PROTON": "",
"UMU_NO_TOOL": "",
}
opts: list[str] = []
prereq: bool = False
Expand Down
Loading
Loading